npm.io
1.3.3 • Published 1 month ago

@dynatrace-sdk/error-handlers

Licence
Apache-2.0
Version
1.3.3
Deps
0
Size
30 kB
Vulns
0
Weekly
0

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.

Keywords