Skip to main content

Overview

All errors thrown by the SDK extend from GrantexError. The hierarchy is designed so you can catch errors at different levels of specificity.

Error hierarchy


GrantexError

The base error class. All SDK errors are instances of GrantexError.

GrantexApiError

Thrown when the Grantex API returns an HTTP error response (4xx or 5xx). Extends GrantexError.

GrantexAuthError

Thrown for authentication and authorization failures (HTTP 401 or 403). Extends GrantexApiError.
Inherits all properties from GrantexApiError.

GrantexTokenError

Thrown when offline token verification fails. This error is raised by verifyGrantToken() and grants.verify(). Extends GrantexError.
Common scenarios:
  • Invalid JWT signature
  • Expired token
  • Missing required JWT claims
  • Missing required scopes (when requiredScopes is specified)
  • Audience mismatch (when audience is specified)

GrantexNetworkError

Thrown when a network error occurs (timeout, DNS resolution failure, connection refused). Extends GrantexError.

Always include err.requestId (from GrantexApiError) in support tickets. It helps the Grantex team trace the exact request in server logs.
Last modified on February 28, 2026