Skip to content
Docs
Reference

Class: BackstageAPIError

Class: BackstageAPIError in @ticketlayer/backstage.

@ticketlayer/backstage


@ticketlayer/backstage / BackstageAPIError

Defined in: client.ts:697

Custom error class for API errors with error code support

Extends#

  • Error

Accessors#

requiredPermission#

Get Signature#

get requiredPermission(): string | undefined;

Defined in: client.ts:762

The permission a refusal names, such as events.create, when this is a permission refusal whose message names one; undefined otherwise.

Returns

string | undefined

Constructors#

Constructor#

new BackstageAPIError(
   message: string, 
   code: string, 
   statusCode: number, 
   info: {
  data?: Record<string, unknown>;
  details?: BackstageAPIErrorDetails;
  moreInfo?: string;
  requestId?: string;
}): BackstageAPIError;

Defined in: client.ts:730

Parameters#

ParameterType
messagestring
codestring
statusCodenumber
info{ data?: Record<string, unknown>; details?: BackstageAPIErrorDetails; moreInfo?: string; requestId?: string; }
info.data?Record<string, unknown>
info.details?BackstageAPIErrorDetails
info.moreInfo?string
info.requestId?string

Returns#

BackstageAPIError

Overrides#

Error.constructor

Methods#

isAuthenticationError()#

isAuthenticationError(): boolean;

Defined in: client.ts:769

Check if this is an authentication error

Returns#

boolean


isNotFound()#

isNotFound(): boolean;

Defined in: client.ts:783

Check if this is a not found error

Returns#

boolean


isPermissionDenied()#

isPermissionDenied(): boolean;

Defined in: client.ts:754

Whether the API refused because the caller lacks a permission, whichever code it answered with (PERMISSION_REFUSAL_CODES): INSUFFICIENT_PERMISSIONS from a route's permission guard (the usual one), PERMISSION_DENIED when the permission is held for some accounts but the operation needs it organisation-wide, ACCOUNT_PERMISSION_DENIED for one account, or FORBIDDEN.

Returns#

boolean


isSessionExpired()#

isSessionExpired(): boolean;

Defined in: client.ts:776

Check if this is a session expired error (401 that couldn't be refreshed)

Returns#

boolean


isValidationError()#

isValidationError(): boolean;

Defined in: client.ts:790

Check if this is a validation error

Returns#

boolean

Properties#

code#

readonly code: string;

Defined in: client.ts:698


data?#

readonly optional data: Record<string, unknown>;

Defined in: client.ts:728

Whatever else the error envelope carried beside message, code and moreInfo: the fields a client acts on by name, such as validationErrors, or neededMediaType and loadedMediaType on a printer media refusal, or releasesAt when a pass's code is not released yet. Absent when the envelope carried nothing more.


details#

readonly details: BackstageAPIErrorDetails;

Defined in: client.ts:720

What the refusal said beside its message and code: alternatives on SEAT_UNAVAILABLE, suggestion and strands on SINGLE_SEAT_GAP, planVersion on PLAN_VERSION_CHANGED, and any other field of the error envelope or its error.details. Empty when it said nothing more.


moreInfo?#

readonly optional moreInfo: string;

Defined in: client.ts:707

The reference page for this error code, carrying the request id: <docs>/error/<CODE>?request=<requestId>. Every Backstage error envelope has one (error.moreInfo); it is absent when the failure was not a Backstage envelope (a proxy, a network error, a session refresh the client gave up on).


requestId?#

readonly optional requestId: string;

Defined in: client.ts:713

The request id the API stamped on this request (metadata.requestId, also echoed as x-request-id). Quote it to support: one id traces the app, the gateway and the API.


statusCode#

readonly statusCode: number;

Defined in: client.ts:699