Classes · @purista/core

HandledError

A handled error is an error which is handled or thrown by business logic. It is wanted to expose it the outside world. Scenarios are input validation failures or "404 Not Found" errors which should be returned to the caller.

Signature

HandledError.tstypescript
class HandledError

Constructors

1 entry

constructor

Constructor

Source
constructor.tstypescript
new constructor(errorCode: StatusCode, message?: string, data?: unknown, traceId?: string)

Properties

3 entries

data

Property

Source
data.tstypescript
data: unknown

errorCode

Property

Source
errorCode.tstypescript
errorCode: StatusCode

traceId

Property

Source
traceId.tstypescript
traceId: string

Methods

5 entries

getErrorResponse

Method

Source
getErrorResponse.tstypescript
getErrorResponse(traceId?: string): Readonly<ErrorResponsePayload>

Returns error response object

toJSON

Method

Source
toJSON.tstypescript
toJSON(): { data: unknown; message: string; name: string; stack: string | undefined; status: StatusCode; traceId: string }

toString

Method

Source
toString.tstypescript
toString(): string

Returns stringified error response object

fromError

Method

Source
fromError.tstypescript
fromError(err: unknown, errorCode?: StatusCode, data?: unknown, traceId?: string): HandledError

Creates a HandledError from an input. If the input error is a HandledError it will be returned without modifications.

fromMessage

Method

Source
fromMessage.tstypescript
fromMessage(message: Readonly<CommandErrorResponse>): HandledError

Create a error object from EBMessage error message