Skip to main content
Extended API error that encompasses both OpenAPI errors and other API-related errors

Extends

  • Error

Constructors

Constructor

new APIError(
   statusCode: number, 
   errorType: APIErrorType, 
   errorMessage: string, 
   correlationId?: string, 
   errorLink?: string, 
   cause?: Error): APIError;
Constructor for the APIError class

Parameters

ParameterTypeDescription
statusCodenumberThe HTTP status code
errorTypeAPIErrorTypeThe type of error
errorMessagestringThe error message
correlationId?stringThe correlation ID
errorLink?stringURL to documentation about this error
cause?ErrorThe cause of the error

Returns

APIError

Overrides

Error.constructor

Methods

toJSON()

toJSON(): {
  errorLink?: string;
  correlationId?: string;
  name: string;
  statusCode: number;
  errorType: APIErrorType;
  errorMessage: string;
};
Convert the error to a JSON object, excluding undefined properties

Returns

{
  errorLink?: string;
  correlationId?: string;
  name: string;
  statusCode: number;
  errorType: APIErrorType;
  errorMessage: string;
}
The error as a JSON object
NameType
errorLink?string
correlationId?string
namestring
statusCodenumber
errorTypeAPIErrorType
errorMessagestring

Properties

PropertyType
statusCodenumber
errorTypeAPIErrorType
errorMessagestring
correlationId?string
errorLink?string