Skip to content

PURISTA API / Modules / @purista/core / UnhandledError

Class: UnhandledError

@purista/core.UnhandledError

A unhandled error will be thrown if some error response is returned during invoking a service function or when the invocation timed out. This error is not handled by business logic and it is maybe unwanted to expose this error outside.

Unhandled error are automatically converted into "500 Internal Server Error" to the outside world.

Hierarchy

  • Error

    UnhandledError

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new UnhandledError(errorCode?, message?, data?, traceId?): UnhandledError

Parameters

NameTypeDefault value
errorCodeStatusCodeStatusCode.InternalServerError
message?stringundefined
data?unknownundefined
traceId?stringundefined

Returns

UnhandledError

Overrides

Error.constructor

Defined in

core/Error/UnhandledError.impl.ts:14

Properties

data

Optional data: unknown

Defined in

core/Error/UnhandledError.impl.ts:17


errorCode

errorCode: StatusCode = StatusCode.InternalServerError

Defined in

core/Error/UnhandledError.impl.ts:15


traceId

Optional traceId: string

Defined in

core/Error/UnhandledError.impl.ts:18

Methods

getErrorResponse

getErrorResponse(): Readonly<ErrorResponsePayload>

Returns error response object

Returns

Readonly<ErrorResponsePayload>

ErrorResponsePayload

Defined in

core/Error/UnhandledError.impl.ts:69


intoHandledError

intoHandledError(): HandledError

Create a handled error from unhandled error

Returns

HandledError

HandledError

Defined in

core/Error/UnhandledError.impl.ts:61


toJSON

toJSON(): Object

Returns

Object

NameTypeDescription
data?unknownaddition data
messagestringa human readable error message
namestring-
stackundefined | string-
statusStatusCodethe error status code
traceId?stringthe trace if of the request

Defined in

core/Error/UnhandledError.impl.ts:88


toString

toString(): string

Returns stringified error response object

Returns

string

ErrorResponse as string

Defined in

core/Error/UnhandledError.impl.ts:84


fromError

fromError(err, errorCode?, data?, traceId?): HandledError

Creates a UnhandledError from an input

Parameters

NameTypeDescription
erranythe input
errorCode?StatusCodethe error code
data?unknownoptional data
traceId?stringoptional trace id

Returns

HandledError

UnhandledError

Defined in

core/Error/UnhandledError.impl.ts:46


fromMessage

fromMessage(message): UnhandledError

Create a error object from EBMessage error message

Parameters

NameTypeDescription
messageReadonly<{ contentEncoding: "utf-8" ; contentType: "application/json" ; correlationId: string ; eventName?: string ; id: string ; isHandledError: boolean ; messageType: CommandErrorResponse ; otp?: string ; payload: { data?: unknown ; message: string ; status: StatusCode } ; principalId?: string ; receiver: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }>CommandErrorResponse

Returns

UnhandledError

UnhandledError

Defined in

core/Error/UnhandledError.impl.ts:33