BUPKIS
    Preparing search index...

    Function isError

    • Type guard for Error instances.

      This function checks if a value is an instance of the Error class or any of its subclasses. It's useful for error handling and type narrowing when working with unknown values that might be errors.

      Parameters

      • value: unknown

        Value to test

      Returns value is Error

      true if the value is an Error instance, false otherwise

      try {
      throw new TypeError('Something went wrong');
      } catch (err) {
      if (isError(err)) {
      // err is now typed as Error
      console.log(err.message);
      }
      }