Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ValidationException

Errors in schema validation.

Validation errors are usually generated based in ValidationResult. If using strict mode, warnings will also raise validation exceptions.

see

BadRequestException

see

ValidationResult

Hierarchy

Index

Constructors

constructor

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 composeMessage

Static fromResults

  • Creates a new ValidationException based on errors in validation results. If validation results have no errors, than null is returned.

    see

    ValidationResult

    Parameters

    • correlationId: string

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

    • results: ValidationResult[]

      list of validation results that may contain errors

    • strict: boolean

      true to treat warnings as errors.

    Returns ValidationException

    a newly created ValidationException or null if no errors in found.

Static throwExceptionIfNeeded

  • throwExceptionIfNeeded(correlationId: string, results: ValidationResult[], strict: boolean): void
  • Throws ValidationException based on errors in validation results. If validation results have no errors, than no exception is thrown.

    see

    ValidationResult

    see

    ValidationException

    Parameters

    • correlationId: string

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

    • results: ValidationResult[]

      list of validation results that may contain errors

    • strict: boolean

      true to treat warnings as errors.

    Returns void

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