1.3.1 • Published 4 months ago

@dynatrace-sdk/error-handlers v1.3.1

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

Error handlers

A Dynatrace AppEngine SDK library allowing to customize how the uncaught errors and rejected promises originating from the app are handled by the AppEngine.

npm install @dynatrace-sdk/error-handlers

Example usage

import {ErrorType, HttpSerializedError, addGlobalErrorSerializer} from "@dynatrace-sdk/error-handlers";

class CustomHttpError {
  constructor(
    readonly status: number,
    readonly name: string,
    readonly message: string,
  ) {
  }
}

addGlobalErrorSerializer(async (error) => {
  if (error instanceof CustomHttpError) {
    return <HttpSerializedError>{
      type: ErrorType.HTTP,
      name: error.name,
      status: error.status,
      message: error.message,
    }
  }
})

API reference

See the package reference in the Dynatrace Developer.