Aller au contenu principal

ErrorClass <Name>

Hierarchy

Index

Constructors

constructor

constructor:

constructor

  • new ErrorClass<Properties>(...properties: ErrorClassParameters<Properties>): Readonly<Error & { cause: unknown; message: string; name: { name: Name } & Properties[name]; stack: string } & { name: Name } & Properties>
  • Error constructor


    Type parameters

    • Properties: Record<string, any> = {}

Properties

readonlyerrorName

errorName: Name

Error name

readonlyprototype

prototype: Readonly<Error & { cause: unknown; message: string; name: string; stack: string } & CustomErrorRequiredProperties>

Methods

asString

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

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

hasInstance

  • 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