The CoercionError is thrown when a value associated with a key cannot be coerced into a another type.

This error helps enforce type safety in parsers by signaling when the value is not a valid value of the target type.

throw new Parser.CoercionError("age", "number");
// Error: Key "age" could not be coerced to number

Hierarchy (View Summary)

Constructors

Properties

cause?: unknown
message: string
name: string = "ParserCoercionError"
stack?: string
prepareStackTrace?: (err: Error, stackTraces: CallSite[]) => any

Optional override for formatting stack traces

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • OptionalconstructorOpt: Function

    Returns void