Base Error: SnackBaseError
All SDK errors extend from the baseSnackBaseError class.
Properties
Properties Reference
| Property | Type | Description |
|---|---|---|
message | string | Human-readable error message |
name | string | Error class name |
code | string | Error code (e.g., “NETWORK_ERROR”) |
status | number | undefined | HTTP status code |
details | any | undefined | Additional error details |
field | string | undefined | Field name (validation) |
retryable | boolean | Whether request can be retried |
Error Classes
AuthenticationError
Status Code: 401 Code:AUTHENTICATION_ERROR
Retryable: No
Thrown when authentication fails or tokens are invalid/expired.
- Invalid credentials
- Expired access token
- Missing authorization header
- Invalid API key
AuthorizationError
Status Code: 403 Code:AUTHORIZATION_ERROR
Retryable: No
Thrown when the authenticated user lacks permission for an action.
- Insufficient permissions
- Role-based access control violation
- Collection rule violation
NotFoundError
Status Code: 404 Code:NOT_FOUND_ERROR
Retryable: No
Thrown when a requested resource is not found.
- Invalid record ID
- Non-existent collection
- Non-existent user/account
ConflictError
Status Code: 409 Code:CONFLICT_ERROR
Retryable: No
Thrown when a resource conflict occurs.
- Duplicate unique field value
- Concurrent modification conflict
- Resource already exists
ValidationError
Status Code: 422 Code:VALIDATION_ERROR
Retryable: No
Thrown when request validation fails.
- Missing required fields
- Invalid field values
- Type mismatch
- Constraint violation
RateLimitError
Status Code: 429 Code:RATE_LIMIT_ERROR
Retryable: Yes
Thrown when rate limit is exceeded.
retryAfter: Seconds to wait before retrying
NetworkError
Status Code: N/A Code:NETWORK_ERROR
Retryable: Yes
Thrown when network request fails.
- No internet connection
- DNS resolution failure
- Connection timeout
- CORS error
TimeoutError
Status Code: N/A Code:TIMEOUT_ERROR
Retryable: Yes
Thrown when a request times out.
- Server not responding
- Slow network
- Large request payload
ServerError
Status Code: 500+ Code:SERVER_ERROR
Retryable: Yes
Thrown when a server error occurs.
- Server-side exception
- Database error
- Configuration error
Error Codes Reference
| Code | Status | Retryable | Error Class |
|---|---|---|---|
AUTHENTICATION_ERROR | 401 | No | AuthenticationError |
AUTHORIZATION_ERROR | 403 | No | AuthorizationError |
NOT_FOUND_ERROR | 404 | No | NotFoundError |
CONFLICT_ERROR | 409 | No | ConflictError |
VALIDATION_ERROR | 422 | No | ValidationError |
RATE_LIMIT_ERROR | 429 | Yes | RateLimitError |
NETWORK_ERROR | N/A | Yes | NetworkError |
TIMEOUT_ERROR | N/A | Yes | TimeoutError |
SERVER_ERROR | 500+ | Yes | ServerError |
Type Guards
Create type guards for specific errors:Error Logging
Log errors with full context:Next Steps
- Error Overview - Error handling guide
- Configuration - Error callback configuration
- Authentication - Authentication errors