Skip to main content

InvariantError

The InvariantError object indicates an error that the program violates a fundamental assumption or condition. This exception is typically used to indicate bugs in the code, such as incorrect assumptions about the state of an object or function. The InvariantError object should be thrown when a violation of an invariant occurs and should not be caught by the program. Instead, it should be handled by the program's error handling mechanism.

Hierarchy

  • Readonly<Error & { cause: unknown; message: string; name: InvariantError; stack: string } & { name: InvariantError }>
    • InvariantError

Index

Constructors

Properties

Methods

Constructors

constructor

  • Error constructor

Properties

staticreadonlyerrorName

errorName: InvariantError

Error name

Methods

staticasString

  • asString(self: Error): string
  • Static method to convert an error to a string

    @example
    CustomError.asString(new Error('my message'));

statichasInstance

  • hasInstance<Class>(this: Class, anyValue: unknown): anyValue is InstanceType<Class>
  • Return true if anyValue is an instance of current class


    Type parameters

    • Class: new (...args: any) => any