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
class HandledError Constructors
1 entry
constructor
Constructor
new constructor(errorCode: StatusCode, message?: string, data?: unknown, traceId?: string) Properties
3 entries
Methods
5 entries
getErrorResponse
Method
getErrorResponse(traceId?: string): Readonly<ErrorResponsePayload> Returns error response object
toJSON
Method
toJSON(): { data: unknown; message: string; name: string; stack: string | undefined; status: StatusCode; traceId: string } toString
Method
toString(): string Returns stringified error response object
fromError
Method
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
fromMessage(message: Readonly<CommandErrorResponse>): HandledError Create a error object from EBMessage error message