Class ErrorParse

Exception to be thrown during parsing failure This is not part of the Polykey exception hierarchy This is because it plain exception wrapper parsing error data While JS allows us to throw POJOs directly, having a nominal type is easier to check against

Hierarchy

  • AbstractError<void>
    • ErrorParse

Constructors

  • Parameters

    • Optional message: string
    • Optional options: {
          cause?: void;
          data?: POJO;
          timestamp?: Date;
      }
      • Optional cause?: void
      • Optional data?: POJO
      • Optional timestamp?: Date

    Returns ErrorParse

Properties

cause: void

Causation of the exception Can be used to know what caused this exception

context: object
data: POJO

Arbitrary data

exitCode: 65 = sysexits.DATAERR
keyPath: string[]
message: string
name: string
stack?: string
timestamp: Date

Timestamp when exception was constructed in milliseconds Guaranteed to be weakly monotonic

value: any
description: string = 'Failed to parse data into valid format'
prepareStackTrace?: ((err, stackTraces) => any)

Type declaration

stackTraceLimit: number

Accessors

  • get description(): string
  • Returns string

Methods

  • Encoding to JSON pojo When overriding this, you can use super.toJSON The replacer will:

    • delete undefined values in objects
    • replace undefined values for null in arrays

    Returns any

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • Optional constructorOpt: Function

    Returns void

  • Runtime decoding of JSON POJO to exception instance When overriding this, you cannot use super.fromJSON You must write it fully, and use the same type-hacks to support polymorphic this in static methods https://github.com/microsoft/TypeScript/issues/5863

    Type Parameters

    • T extends Class<any>

    Parameters

    • this: T
    • json: any

    Returns InstanceType<T>

Generated using TypeDoc