@dynatrace-sdk/shared-errors

中文文档
1.1.0发布于 2026/10/29Apache-2.0TypeScriptESM + CJS近 30 天下载 2.6万

Shared error classes for autogenerated Dynatrace SDK packages.

原始使用文档
文档目录17 节
  1. title: "@dynatrace-sdk/shared-errors" description: Shared e…
  2. Classes
  3. ApiClientError
  4. ApiGatewayError
  5. ClientRequestError
  6. InvalidResponseError
  7. Functions
  8. isApiClientError
  9. isApiGatewayError
  10. isClientRequestError
  11. isInvalidResponseError
  12. Types
  13. ApiGatewayErrorDetails
  14. CommonApiError
  15. CommonErrorDetails
  16. ConstraintViolation
  17. ErrorResponseBody

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

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

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
response*requiredHttpClientResponse
retryAfterSeconds*requiredundefined | 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

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

Properties

NameTypeDescription
body*requiredDTO
causeany
errorType*requiredErrorType
isApiClientError*requiredtrue
isClientRequestError*requiredtrue
response*requiredHttpClientResponse

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
nestedErrorError
response*requiredany
responseBody*requiredany

Functions

isApiClientError

isApiClientError(e):

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

Parameters

NameType
e*requiredany
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

NameType
e*requiredany
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

NameType
e*requiredany
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.

Also returns true for DataTypeError instances thrown by @dynatrace-sdk/http-client when a response body cannot be decoded as the expected type (e.g. the server returned text/html but the SDK requested application/json). Treating those as InvalidResponseError lets app code handle "the response did not match the expected schema" with a single type guard.

Parameters

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

Types

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.
errorCodestring

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.

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*requirednumber

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.

detailsT

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

helpstring

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*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.
errorCodestring

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.

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*requiredT

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

版本与发布记录

@dynatrace-sdk/shared-errors 共发布 7 个版本,首次发布于 2024/09/10;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.1.0latest2026/10/2915 天前
1.0.22025/09/171.2 年前
1.0.12025/07/151.3 年前
1.0.02024/09/242 年前
0.0.42024/09/232 年前
0.0.32024/09/232 年前

关于 @dynatrace-sdk/shared-errors 的常见问题

@dynatrace-sdk/shared-errors 是什么?

Shared error classes for autogenerated Dynatrace SDK packages.

如何安装 @dynatrace-sdk/shared-errors?

在项目目录运行 npm install @dynatrace-sdk/shared-errors,或使用 pnpm add / yarn add / bun add。

@dynatrace-sdk/shared-errors 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dynatrace-sdk/shared-errors 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dynatrace-sdk/shared-errors 可以商用吗?

@dynatrace-sdk/shared-errors 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@dynatrace-sdk/shared-errors 的下载量有多少?

根据 npm 官方下载统计,@dynatrace-sdk/shared-errors 在 2026/10/13 – 2026/11/11 这 30 天内被下载 26,014 次,日均约 867 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dynatrace-sdk/shared-errors 还在维护吗?

最新版本 1.1.0 发布于 2026/10/29(15 天前);至今共发布 7 个版本,其中过去 12 个月发布了 1 个;首次发布于 2024/09/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。