Skip to main content
This is a complete reference for all error types in the SnackBase JavaScript SDK.

Base Error: SnackBaseError

All SDK errors extend from the base SnackBaseError class.

Properties

Properties Reference

Error Classes

AuthenticationError

Status Code: 401 Code: AUTHENTICATION_ERROR Retryable: No Thrown when authentication fails or tokens are invalid/expired.
Common Causes:
  • Invalid credentials
  • Expired access token
  • Missing authorization header
  • Invalid API key
Example:

AuthorizationError

Status Code: 403 Code: AUTHORIZATION_ERROR Retryable: No Thrown when the authenticated user lacks permission for an action.
Common Causes:
  • Insufficient permissions
  • Role-based access control violation
  • Collection rule violation
Example:

NotFoundError

Status Code: 404 Code: NOT_FOUND_ERROR Retryable: No Thrown when a requested resource is not found.
Common Causes:
  • Invalid record ID
  • Non-existent collection
  • Non-existent user/account
Example:

ConflictError

Status Code: 409 Code: CONFLICT_ERROR Retryable: No Thrown when a resource conflict occurs.
Common Causes:
  • Duplicate unique field value
  • Concurrent modification conflict
  • Resource already exists
Example:

ValidationError

Status Code: 422 Code: VALIDATION_ERROR Retryable: No Thrown when request validation fails.
Common Causes:
  • Missing required fields
  • Invalid field values
  • Type mismatch
  • Constraint violation
Example:

RateLimitError

Status Code: 429 Code: RATE_LIMIT_ERROR Retryable: Yes Thrown when rate limit is exceeded.
Properties:
  • retryAfter: Seconds to wait before retrying
Example:

NetworkError

Status Code: N/A Code: NETWORK_ERROR Retryable: Yes Thrown when network request fails.
Common Causes:
  • No internet connection
  • DNS resolution failure
  • Connection timeout
  • CORS error
Example:

TimeoutError

Status Code: N/A Code: TIMEOUT_ERROR Retryable: Yes Thrown when a request times out.
Common Causes:
  • Server not responding
  • Slow network
  • Large request payload
Example:

ServerError

Status Code: 500+ Code: SERVER_ERROR Retryable: Yes Thrown when a server error occurs.
Common Causes:
  • Server-side exception
  • Database error
  • Configuration error
Example:

Error Codes Reference

Type Guards

Create type guards for specific errors:

Error Logging

Log errors with full context:

Next Steps