Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InvalidStateException

Errors related to calling operations, which require the component to be in a specific state.

For instance: business calls when the component is not ready.

Hierarchy

Index

Constructors

constructor

  • new InvalidStateException(correlation_id?: string, code?: string, message?: string): InvalidStateException
  • Creates an error instance and assigns its values.

    see

    ErrorCategory

    Parameters

    • Default value correlation_id: string = null

      (optional) a unique transaction id to trace execution through call chain.

    • Default value code: string = null

      (optional) a unique error code. Default: "UNKNOWN"

    • Default value message: string = null

      (optional) a human-readable description of the error.

    Returns InvalidStateException

Properties

category

category: string

Standard error category

cause

cause: string

Original error wrapped by this exception

code

code: string = "UNKNOWN"

A unique error code

correlation_id

correlation_id: string

A unique transaction id to trace execution throug call chain

details

A map with additional details that can be used to restore error description in other languages

message

message: string

A human-readable error description (usually written in English)

stack_trace

stack_trace: string

Stack trace of the exception

status

status: number = 500

HTTP status code associated with this error type

Static message

message: string

Static name

name: string

Static Optional stack

stack: string

Methods

getCauseString

  • getCauseString(): string

getStackTraceString

  • getStackTraceString(): string

setCauseString

  • setCauseString(value: string): void

setStackTraceString

  • setStackTraceString(value: string): void

withCause

withCode

withCorrelationId

withDetails

  • Sets a parameter for additional error details. This details can be used to restore error description in other languages.

    This method returns reference to this exception to implement Builder pattern to chain additional calls.

    Parameters

    • key: string

      a details parameter name

    • value: any

      a details parameter name

    Returns ApplicationException

    this exception object

withStackTrace

withStatus

wrap

  • Wraps another exception into an application exception object.

    If original exception is of ApplicationException type it is returned without changes. Otherwise a new ApplicationException is created and original error is set as its cause.

    Parameters

    • cause: any

      an original error object

    Returns ApplicationException

    an original or newly created ApplicationException

Static unwrapError

  • unwrapError(error: any): any
  • Unwraps original exception through wrapped exception objects.

    Many frameworks like Seneca or restify wrap original exception. That may result in propagating less specific errors and can hide causes of the errors.

    Parameters

    • error: any

      an error object

    Returns any

    an original error object

Static wrapError

  • Wraps another exception into specified application exception object.

    If original exception is of ApplicationException type it is returned without changes. Otherwise the original error is set as a cause to specified ApplicationException object.

    see

    wrap

    Parameters

    • error: ApplicationException

      an ApplicationException object to wrap the cause

    • cause: any

      an original error object

    Returns ApplicationException

    an original or newly created ApplicationException

Generated using TypeDoc