Skip to main content

Class: Error

@ima/core.Error

The IMA application error extends the native Error with additional details that lead to the error and the HTTP status code to send to the client.

Implementation note: This is an interface that extends the abstract class ExtensibleError, which does not make much sense from the strict OOP standpoint, but is necessary due to limitations of JavaScript, so that IMA errors are instances of both the native errors and of this interface.

Hierarchy

Constructors

constructor

new Error(message, dropInternalStackFrames?)

Parameters

NameTypeDefault value
messagestringundefined
dropInternalStackFramesbooleantrue

Inherited from

ExtensibleError.constructor

Defined in

packages/core/src/error/ExtensibleError.ts:43

Properties

_dropInternalStackFrames

Protected _dropInternalStackFrames: boolean

Inherited from

ExtensibleError._dropInternalStackFrames

Defined in

packages/core/src/error/ExtensibleError.ts:15


cause

Optional cause: unknown

Inherited from

ExtensibleError.cause

Defined in

node_modules/typescript/lib/lib.es2022.error.d.ts:26


message

message: string

Inherited from

ExtensibleError.message

Defined in

node_modules/typescript/lib/lib.es5.d.ts:1054


name

name: string

Inherited from

ExtensibleError.name

Defined in

node_modules/typescript/lib/lib.es5.d.ts:1053


prepareStackTrace

Static Optional prepareStackTrace: (err: Error, stackTraces: CallSite[]) => any

Type declaration

▸ (err, stackTraces): any

Optional override for formatting stack traces

See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

Parameters
NameType
errError
stackTracesCallSite[]
Returns

any

Inherited from

ExtensibleError.prepareStackTrace

Defined in

node_modules/@types/node/globals.d.ts:11


stackTraceLimit

Static stackTraceLimit: number

Inherited from

ExtensibleError.stackTraceLimit

Defined in

node_modules/@types/node/globals.d.ts:13

Accessors

stack

get stack(): undefined | string

Returns

undefined | string

Inherited from

ExtensibleError.stack

Defined in

packages/core/src/error/ExtensibleError.ts:17

Methods

getHttpStatus

getHttpStatus(): number

Returns the HTTP status to send to the client.

If the error has occurred at the client-side, the status code is used to determine the error page to show to the user.

This method is a shorthand for the following code snippet: this.getParams().status || 500.

See

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Returns

number

The HTTP status to send to the client.

Defined in

packages/core/src/error/Error.ts:26


getParams

getParams(): UnknownParameters

Returns the error parameters providing additional details about the error. The structure of the returned object is always situation-dependent, but the returned object usually contains the status: number field which represents the HTTP status to send to the client.

See

Error#getHttpStatus

Returns

UnknownParameters

The route parameters of the route at which the error has occurred.

Defined in

packages/core/src/error/Error.ts:41


captureStackTrace

Static captureStackTrace(targetObject, constructorOpt?): void

Create .stack property on a target object

Parameters

NameType
targetObjectobject
constructorOpt?Function

Returns

void

Inherited from

ExtensibleError.captureStackTrace

Defined in

node_modules/@types/node/globals.d.ts:4