Skip to main content

MandataApiError

@mandaitor/sdk


@mandaitor/sdk / MandataApiError

Class: MandataApiError

Defined in: packages/sdk/src/errors.ts:60

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 MandataApiError) {
if (err.code === ErrorCodes.MANDATE_NOT_FOUND) {
// Handle 404
}
console.error(`[${err.status}] ${err.code}: ${err.message}`);
}
}

Extends

  • Error

Constructors

Constructor

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

Defined in: packages/sdk/src/errors.ts:63

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

MandataApiError

Overrides

Error.constructor

Properties

cause?

optional cause: unknown

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

Inherited from

Error.cause


code

readonly code: string

Defined in: packages/sdk/src/errors.ts:67

Machine-readable error code from ErrorCodes


message

message: string

Defined in: node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:1077

Inherited from

Error.message


name

readonly name: "MandataApiError" = "MandataApiError"

Defined in: packages/sdk/src/errors.ts:61

Overrides

Error.name


requestId?

readonly optional requestId: string

Defined in: packages/sdk/src/errors.ts:71

Optional request ID for support debugging


stack?

optional stack: string

Defined in: node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:1078

Inherited from

Error.stack


status

readonly status: number

Defined in: packages/sdk/src/errors.ts:65

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


prepareStackTrace()?

static optional prepareStackTrace: (err, stackTraces) => any

Defined in: node_modules/.pnpm/@types+node@22.7.9/node_modules/@types/node/globals.d.ts:143

Optional override for formatting stack traces

Parameters

err

Error

stackTraces

CallSite[]

Returns

any

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Inherited from

Error.prepareStackTrace


stackTraceLimit

static stackTraceLimit: number

Defined in: node_modules/.pnpm/@types+node@22.7.9/node_modules/@types/node/globals.d.ts:145

Inherited from

Error.stackTraceLimit

Accessors

isClientError

Get Signature

get isClientError(): boolean

Defined in: packages/sdk/src/errors.ts:79

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

Returns

boolean


isRetryable

Get Signature

get isRetryable(): boolean

Defined in: packages/sdk/src/errors.ts:84

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

Returns

boolean

Methods

toJSON()

toJSON(): object

Defined in: packages/sdk/src/errors.ts:89

Structured JSON representation for logging

Returns

object

code

code: string

message

message: string

name

name: string

requestId

requestId: string | undefined

status

status: number


captureStackTrace()

static captureStackTrace(targetObject, constructorOpt?): void

Defined in: node_modules/.pnpm/@types+node@22.7.9/node_modules/@types/node/globals.d.ts:136

Create .stack property on a target object

Parameters

targetObject

object

constructorOpt?

Function

Returns

void

Inherited from

Error.captureStackTrace