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
Name | Type | Default value |
---|---|---|
errorCode | StatusCode | StatusCode.InternalServerError |
message? | string | undefined |
data? | unknown | undefined |
traceId? | string | undefined |
Returns
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
Defined in
core/Error/UnhandledError.impl.ts:61
toJSON
▸ toJSON(): Object
Returns
Object
Name | Type | Description |
---|---|---|
data? | unknown | addition data |
message | string | a human readable error message |
name | string | - |
stack | undefined | string | - |
status | StatusCode | the error status code |
traceId? | string | the 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
Name | Type | Description |
---|---|---|
err | any | the input |
errorCode? | StatusCode | the error code |
data? | unknown | optional data |
traceId? | string | optional trace id |
Returns
UnhandledError
Defined in
core/Error/UnhandledError.impl.ts:46
fromMessage
▸ fromMessage(message
): UnhandledError
Create a error object from EBMessage error message
Parameters
Name | Type | Description |
---|---|---|
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