@grabjs/superapp-sdk
    Preparing search index...

    Function isErrorWithMessage

    • Type guard to check if an error has a message property. Use this to safely narrow unknown errors in catch blocks.

      Parameters

      • error: unknown

        The error value (typically from a catch block)

      Returns error is { message: string }

      True if the error has a string message property

      try {
      await riskyOperation();
      } catch (error) {
      if (isErrorWithMessage(error)) {
      console.error(error.message); // TypeScript knows error has message
      }
      }