The InvalidInstanceOfError is thrown when a value associated with a key is not an instance of the expected class or constructor.

This error is useful when checking for object instances (e.g., Date, File) and enforcing that the value matches the expected class.

throw new Parser.InvalidInstanceOfError("createdAt", "Date");
// Error: Key "createdAt" expected instance of Date

Hierarchy (View Summary)

  • Error
    • InvalidInstanceOfError

Constructors

Properties

cause?: unknown
message: string
name: string = "ParserInvalidInstanceOfError"
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