Result<T, E> rather than throwing exceptions.
Result pattern
Error types
All errors have a_tag property for type discrimination.
NetworkError
Connection failures, timeouts, and aborted requests.ApiError
Server errors, rate limits, and GraphQL errors.
Some
ApiErrors report config drift rather than a transient failure. A 401 usually means the storefront token is missing or invalid. Messages like "The selected sort order code is invalid." and "The selected facets.N is invalid." mean a registered sorts[].code or facets[].code no longer exists in the Layers dashboard. See Troubleshooting for fixes.
ValidationError
Invalid parameters passed to SDK methods.ConfigError
SDK configuration issues at init time.Error helpers
The SDK provides utility functions for handling retryable errors:Error handling with reactive state
Handle errors reactively using the controller’ssubscribe method. This approach works with any framework: