Skip to main content
The SnackBase SDK provides a comprehensive error handling system with typed error classes for different failure scenarios.

Overview

All SDK errors extend from the base SnackBaseError class, allowing you to catch errors generically or handle specific error types:

Error Hierarchy

Error Properties

All errors include the following properties:

Error Types

AuthenticationError (401)

Thrown when authentication fails or tokens are invalid:

AuthorizationError (403)

Thrown when the user lacks permission for an action:

NotFoundError (404)

Thrown when a resource is not found:

ConflictError (409)

Thrown when a resource conflict occurs (e.g., duplicate):

ValidationError (422)

Thrown when request validation fails:

RateLimitError (429)

Thrown when rate limit is exceeded:

NetworkError

Thrown when network request fails:

TimeoutError

Thrown when request times out:

ServerError (500+)

Thrown when server error occurs:

Global Error Handlers

Configure global error callbacks:

React Error Handling

Retry Logic

Check if error is retryable:

Custom Error Handler

Create a custom error handler:

Complete Example

Next Steps