Backstage
    Preparing search index...

    Function isErrorWithName

    • Checks whether a value is error-shaped and has the given explicit name. Any defined cause must also be error-shaped.

      This uses lightweight shape checks rather than constructor identity, so it works across package copies and after error serialization. A matching name is assumed to identify the intended error type; additional fields are not validated. Custom type guards should check any additional fields they need.

      Type Parameters

      • TName extends string

      Parameters

      • value: unknown

        an unknown value

      • name: TName

        the expected error name

      Returns value is ErrorLike & { cause?: ErrorLike; name: TName }

      true if the value has the expected error name and basic shape

      class MyError extends CustomErrorBase {
      name = 'MyError' as const;

      static is(value: unknown): value is MyError {
      return isErrorWithName(value, 'MyError');
      }
      }