1.0.0 • Published 9 months ago

@dynatrace-sdk/shared-errors v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
9 months ago

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

NameType
name*requiredstring
messagestring
causeany

Properties

NameTypeDescription
causeany
errorType*requiredErrorType
isApiClientError*requiredtrue
message*requiredstring
name*requiredstring
stackstring
prepareStackTraceObjectOptional override for formatting stack traces
stackTraceLimit*requirednumber

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

NameType
response*requiredHttpClientResponse
body*requiredApiGatewayErrorResponseBody

Properties

NameTypeDescription
body*requiredApiGatewayErrorResponseBody
causeany
code*requirednumber
errorType*requiredErrorType
isApiClientError*requiredtrue
isApiGatewayError*requiredtrue
isClientRequestError*requiredtrue
message*requiredstring
name*requiredstring
response*requiredHttpClientResponse
retryAfterSeconds*requiredundefined | number
stackstring
prepareStackTraceObjectOptional override for formatting stack traces
stackTraceLimit*requirednumber

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

NameType
name*requiredstring
response*requiredHttpClientResponse
body*requiredDTO
messagestring
causeany

Properties

NameTypeDescription
body*requiredDTO
causeany
errorType*requiredErrorType
isApiClientError*requiredtrue
isClientRequestError*requiredtrue
message*requiredstring
name*requiredstring
response*requiredHttpClientResponse
stackstring
prepareStackTraceObjectOptional override for formatting stack traces
stackTraceLimit*requirednumber

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

NameType
name*requiredstring
nestedError*requiredany
body*requiredany
expectedTypestring
messagestring
responseany

Properties

NameTypeDescription
causeany
errorType*requiredErrorType
expectedTypestring
isApiClientError*requiredtrue
isInvalidResponseError*requiredtrue
message*requiredstring
name*requiredstring
nestedErrorError
response*requiredany
responseBody*requiredany
stackstring
prepareStackTraceObjectOptional override for formatting stack traces
stackTraceLimit*requirednumber

Interfaces

ApiGatewayErrorDetails

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

Properties

NameTypeDescription
constraintViolationsArray<ConstraintViolation>An array of ConstraintViolation object, refer to ConstraintViolation object reference for more details.
errorCodestringString 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.
errorCodePropertiesObject
errorRefstringUUID string that represents a reference of the error into e.g., the log file of the service.
missingPermissionsArray<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.
missingScopesArray<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.
traceIdstringString containing a 32-character hex integer value that is used for tracing.

CommonApiError

Common API error structure, established by Dynatrace API guidelines.

Properties

NameTypeDescription
code*requirednumberThe 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.
detailsTAdditional details about the error may be added in a details field. Refer to CommonErrorDetails
helpstringAn 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*requiredstringThe 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

NameTypeDescription
constraintViolationsArray<ConstraintViolation>An array of ConstraintViolation object, refer to ConstraintViolation object reference for more details.
errorCodestringString 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.
errorRefstringUUID string that represents a reference of the error into e.g., the log file of the service.
missingPermissionsArray<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.
missingScopesArray<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.
traceIdstringString 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

NameTypeDescription
message*requiredstringMandatory field message describing the warning.
parameterLocationstringDescribes the general location of the violating parameter (query parameter, request body, etc.)
pathstringRefers to the violating parameter within the parameterLocation.

ErrorResponseBody

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

Properties

NameTypeDescription
error*requiredTerror 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

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

Parameters

NameType
e*requiredany
try {
  doSomething();
} catch (e: unknown) {
  if(isApiClientError(e)) {
    handleTheError();
  }
}

isApiGatewayError

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

Parameters

NameType
e*requiredany
try {
  doSomething();
} catch (e: unknown) {
  if(isApiClientError(e)) {
    handleTheError();
  }
}

isClientRequestError

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

Parameters

NameType
e*requiredany
try {
  doSomething();
} catch (e: unknown) {
  if(isClientRequestError(e)) {
    handleTheError();
  }
}

isInvalidResponseError

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

Parameters

NameType
e*requiredany
try {
   doSomething();
} catch (e: unknown) {
   if (isInvalidResponseError(e)) {
     throw e;
   }
}