PURISTA API / @purista/core / UnhandledError
Class: UnhandledError
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:13
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.
Extends
Error
Constructors
new UnhandledError()
new UnhandledError(
errorCode
,message
?,data
?,traceId
?):UnhandledError
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:14
Parameters
errorCode
StatusCode
= StatusCode.InternalServerError
message?
string
data?
unknown
traceId?
string
Returns
Overrides
Error.constructor
Properties
data?
optional
data:unknown
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:17
errorCode
errorCode:
StatusCode
=StatusCode.InternalServerError
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:15
traceId?
optional
traceId:string
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:18
Methods
getErrorResponse()
getErrorResponse():
Readonly
<ErrorResponsePayload
>
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:69
Returns error response object
Returns
Readonly
<ErrorResponsePayload
>
ErrorResponsePayload
intoHandledError()
intoHandledError():
HandledError
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:61
Create a handled error from unhandled error
Returns
HandledError
toJSON()
toJSON():
object
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:88
Returns
object
data?
optional
data:unknown
addition data
message
message:
string
a human readable error message
name
name:
string
stack
stack:
undefined
|string
status
status:
StatusCode
the error status code
traceId?
optional
traceId:string
the trace if of the request
toString()
toString():
string
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:84
Returns stringified error response object
Returns
string
ErrorResponse as string
fromError()
static
fromError(err
,errorCode
?,data
?,traceId
?):HandledError
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:46
Creates a UnhandledError from an input
Parameters
err
any
the input
errorCode?
the error code
data?
unknown
optional data
traceId?
string
optional trace id
Returns
UnhandledError
fromMessage()
static
fromMessage(message
):UnhandledError
Defined in: packages/core/src/core/Error/UnhandledError.impl.ts:33
Create a error object from EBMessage error message
Parameters
message
Readonly
<{ 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