@dynatrace-sdk/shared-errors
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

title: "@dynatrace-sdk/shared-errors" description: Shared error classes for autogenerated Dynatrace SDK packages.

@dynatrace-sdk/shared-errors

Shared error classes for autogenerated Dynatrace SDK packages.

npm install @dynatrace-sdk/shared-errors

Classes

ApiClientError

Base error for all client SDKs. All other errors extend this class.

Constructors

new ApiClientError(name,message?,cause?)

Parameters

Name Type
name*required string
message string
cause any

Properties

Name Type Description
cause any
errorType*required ErrorType
isApiClientError*required true
message*required string
name*required string
stack string
prepareStackTrace Object Optional override for formatting stack traces
stackTraceLimit*required number

ApiGatewayError

Dedicated error response class for errors thrown by API Gateway. Autogenerated SDK Clients have built-in handler for API Gateway errors that throws this error.

Constructors

new ApiGatewayError(response,body)

Parameters

Name Type
response*required HttpClientResponse
body*required ApiGatewayErrorResponseBody

Properties

Name Type Description
body*required ApiGatewayErrorResponseBody
cause any
code*required number
errorType*required ErrorType
isApiClientError*required true
isApiGatewayError*required true
isClientRequestError*required true
message*required string
name*required string
response*required HttpClientResponse
retryAfterSeconds*required undefined | number
stack string
prepareStackTrace Object Optional override for formatting stack traces
stackTraceLimit*required number

ClientRequestError

Generic error class for service errors, used to handle both expected and unexpected service-level errors.

Constructors

new ClientRequestError(name,response,body,message?,cause?)

Parameters

Name Type
name*required string
response*required HttpClientResponse
body*required DTO
message string
cause any

Properties

Name Type Description
body*required DTO
cause any
errorType*required ErrorType
isApiClientError*required true
isClientRequestError*required true
message*required string
name*required string
response*required HttpClientResponse
stack string
prepareStackTrace Object Optional override for formatting stack traces
stackTraceLimit*required number

InvalidResponseError

Dedicated error class for errors related to response serialization. Thrown when received service response can't be deserialized.

Constructors

new InvalidResponseError(name,nestedError,body,expectedType?,message?,response?)

Parameters

Name Type
name*required string
nestedError*required any
body*required any
expectedType string
message string
response any

Properties

Name Type Description
cause any
errorType*required ErrorType
expectedType string
isApiClientError*required true
isInvalidResponseError*required true
message*required string
name*required string
nestedError Error
response*required any
responseBody*required any
stack string
prepareStackTrace Object Optional override for formatting stack traces
stackTraceLimit*required number

Interfaces

ApiGatewayErrorDetails

Reference for ApiGatewayError details object. Contains information about received API Getaway error.

Properties

Name Type Description
constraintViolations Array<ConstraintViolation> An array of ConstraintViolation object, refer to ConstraintViolation object reference for more details.
errorCode string

String value representing a more detailed error information than the http response code alone. Must be a single word in CamelCase, and all possible values must be documented.

errorCodeProperties Object
errorRef string UUID string that represents a reference of the error into e.g., the log file of the service.
missingPermissions Array<string>

Must be an array of strings containing a complete list of missing IAM permissions necessary to successfully execute the request. Should be set if the API returns a 403 - Forbidden response in case of missing OAuth user permissions.

missingScopes Array<string>

Must be an array of strings containing a complete list of missing IAM scopes necessary to successfully execute the request. Should be set if the API returns a 403 - Forbidden response in case of missing OAuth scopes.

traceId string String containing a 32-character hex integer value that is used for tracing.

CommonApiError

Common API error structure, established by Dynatrace API guidelines.

Properties

Name Type Description
code*required number

The error code should be set to the HTTP error code by default.

The error code may be set to an API-specific error code which must be properly documented.

details T

Additional details about the error may be added in a details field. Refer to CommonErrorDetails

help string

An additional help field may be added which must be a URL to further information on how to deal with the error.

This may be some detailed error documentation page or a link to the Dynatrace support system, etc.

message*required string The error message should be short and precise, it should not contain details.

CommonErrorDetails

CommonApiError details object reference. Contains common API error information. This object is used to convey additional information about the error like e.g., which query parameter exactly violated a precondition.

Details may contain any fields to further describe the error

Properties

Name Type Description
constraintViolations Array<ConstraintViolation> An array of ConstraintViolation object, refer to ConstraintViolation object reference for more details.
errorCode string

String value representing a more detailed error information than the http response code alone. Must be a single word in CamelCase, and all possible values must be documented.

errorRef string UUID string that represents a reference of the error into e.g., the log file of the service.
missingPermissions Array<string>

Must be an array of strings containing a complete list of missing IAM permissions necessary to successfully execute the request. Should be set if the API returns a 403 - Forbidden response in case of missing OAuth user permissions.

missingScopes Array<string>

Must be an array of strings containing a complete list of missing IAM scopes necessary to successfully execute the request. Should be set if the API returns a 403 - Forbidden response in case of missing OAuth scopes.

traceId string String containing a 32-character hex integer value that is used for tracing.

ConstraintViolation

Contains information about an input parameter (path, query or request body) that violated some validation rule of the service API and caused the warning.

May contain additional fields further describing the warning.

Properties

Name Type Description
message*required string Mandatory field message describing the warning.
parameterLocation string Describes the general location of the violating parameter (query parameter, request body, etc.)
path string Refers to the violating parameter within the parameterLocation.

ErrorResponseBody

Basic error envelope, that enforces all error to have mandatory "error" property.

Properties

Name Type Description
error*required T

error object must have two mandatory fields (code, message) and may have two additional fields (help, details): refer to the CommonApiError for more details.

Functions

isApiClientError

isApiClientError(e):

ApiClientError type guard function. Does a structural check of the passed object.

Parameters

Name Type
e*required any
Code example
try {
  doSomething();
} catch (e: unknown) {
  if(isApiClientError(e)) {
    handleTheError();
  }
}

isApiGatewayError

isApiGatewayError(e):

APIGatewayError type guard function. Does a structural check of the passed object.

Parameters

Name Type
e*required any
Code example
try {
  doSomething();
} catch (e: unknown) {
  if(isApiClientError(e)) {
    handleTheError();
  }
}

isClientRequestError

isClientRequestError(e):

ClientRequestError type guard function. Does a structural check of the passed object.

Parameters

Name Type
e*required any
Code example
try {
  doSomething();
} catch (e: unknown) {
  if(isClientRequestError(e)) {
    handleTheError();
  }
}

isInvalidResponseError

isInvalidResponseError(e):

InvalidResponseError type guard function. Does a structural check of the passed object.

Parameters

Name Type
e*required any
Code example
try {
   doSomething();
} catch (e: unknown) {
   if (isInvalidResponseError(e)) {
     throw e;
   }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @dynatrace-sdk/shared-errors

Weekly Downloads

2,583

Version

1.0.0

License

Apache-2.0

Unpacked Size

41 kB

Total Files

13

Last publish

Collaborators

  • stefan.wolfsteiner.dynatrace
  • dynatrace-nodejs
  • wasserb