Skip to main content

MandaitorApiError

@mandaitor/sdk


@mandaitor/sdk / MandaitorApiError

Class: MandaitorApiError

Defined in: @mandaitor/sdk/dist/errors.d.ts:44

Typed error class for Mandaitor API errors. Thrown by MandaitorClient when the API returns a non-2xx response.

Example​

try {
await client.getMandate("mnd_nonexistent");
} catch (err) {
if (err instanceof MandaitorApiError) {
if (err.code === ErrorCodes.MANDATE_NOT_FOUND) {
// Handle 404
}
console.error(`[${err.status}] ${err.code}: ${err.message}`);
}
}

Extends​

  • Error

Extended by​

Constructors​

Constructor​

new MandaitorApiError(status, code, message, requestId?): MandaitorApiError

Defined in: @mandaitor/sdk/dist/errors.d.ts:52

Parameters​

status​

number

HTTP status code (e.g. 400, 404, 500)

code​

string

Machine-readable error code from ErrorCodes

message​

string

Human-readable error message

requestId?​

string

Optional request ID for support debugging

Returns​

MandaitorApiError

Overrides​

Error.constructor

Properties​

cause?​

optional cause?: unknown

Defined in: .pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts:24

Inherited from​

Error.cause


code​

readonly code: string

Defined in: @mandaitor/sdk/dist/errors.d.ts:48

Machine-readable error code from ErrorCodes


message​

message: string

Defined in: .pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1075

Inherited from​

Error.message


name​

readonly name: string

Defined in: @mandaitor/sdk/dist/errors.d.ts:51

Overrides​

Error.name


requestId?​

readonly optional requestId?: string

Defined in: @mandaitor/sdk/dist/errors.d.ts:50

Optional request ID for support debugging


stack?​

optional stack?: string

Defined in: .pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts:1076

Inherited from​

Error.stack


status​

readonly status: number

Defined in: @mandaitor/sdk/dist/errors.d.ts:46

HTTP status code (e.g. 400, 404, 500)

Accessors​

isClientError​

Get Signature​

get isClientError(): boolean

Defined in: @mandaitor/sdk/dist/errors.d.ts:62

Returns true if this is a client error (4xx)

Returns​

boolean


isRetryable​

Get Signature​

get isRetryable(): boolean

Defined in: @mandaitor/sdk/dist/errors.d.ts:64

Returns true if this is a server error (5xx) — safe to retry

Returns​

boolean

Methods​

toJSON()​

toJSON(): object

Defined in: @mandaitor/sdk/dist/errors.d.ts:66

Structured JSON representation for logging

Returns​

object

code​

code: string

message​

message: string

name​

name: string

requestId​

requestId: string | undefined

status​

status: number