title: "@dynatrace-sdk/shared-errors" description: Shared error classes for autogenerated Dynatrace SDK packages.
Shared error classes for autogenerated Dynatrace SDK packages.
npm install @dynatrace-sdk/shared-errors
Base error for all client SDKs. All other errors extend this class.
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 |
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.
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 |
Generic error class for service errors, used to handle both expected and unexpected service-level errors.
Name | Type |
---|---|
name*required | string |
response*required | HttpClientResponse |
body*required | DTO |
message | string |
cause | any |
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 |
Dedicated error class for errors related to response serialization. Thrown when received service response can't be deserialized.
Name | Type |
---|---|
name*required | string |
nestedError*required | any |
body*required | any |
expectedType | string |
message | string |
response | any |
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 |
Reference for ApiGatewayError details object. Contains information about received API Getaway error.
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. |
Common API error structure, established by Dynatrace API guidelines.
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. |
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
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. |
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.
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. |
Basic error envelope, that enforces all error to have mandatory "error" property.
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. |
ApiClientError type guard function. Does a structural check of the passed object.
Name | Type |
---|---|
e*required | any |
Code example
try {
doSomething();
} catch (e: unknown) {
if(isApiClientError(e)) {
handleTheError();
}
}
APIGatewayError type guard function. Does a structural check of the passed object.
Name | Type |
---|---|
e*required | any |
Code example
try {
doSomething();
} catch (e: unknown) {
if(isApiClientError(e)) {
handleTheError();
}
}
ClientRequestError type guard function. Does a structural check of the passed object.
Name | Type |
---|---|
e*required | any |
Code example
try {
doSomething();
} catch (e: unknown) {
if(isClientRequestError(e)) {
handleTheError();
}
}
InvalidResponseError type guard function. Does a structural check of the passed object.
Name | Type |
---|---|
e*required | any |
Code example
try {
doSomething();
} catch (e: unknown) {
if (isInvalidResponseError(e)) {
throw e;
}
}