The SDK throws four error types. Always check forDocumentation Index
Fetch the complete documentation index at: https://docs.usehasp.com/llms.txt
Use this file to discover all available pages before exploring further.
AbortError first (request cancellation), then NetworkError, then MaintenanceError, then the base HaspSDKError.
Error Types
DOMException (AbortError)
Thrown when a request is cancelled viaAbortSignal or sdk.destroy(). This is not a network or server error.
NetworkError
Thrown when thefetch() call itself fails — device offline, DNS failure, etc. GET requests are retried automatically before this fires.
MaintenanceError
Thrown proactively when write operations are attempted while the SDK is in maintenance state.HaspSDKError
The base class for all server-side errors. Checkerror.code against ErrorCode constants.
Complete Pattern
ErrorCode Constants
| Constant | Value | When thrown |
|---|---|---|
ErrorCode.Unauthorized | UNAUTHORIZED | Session expired |
ErrorCode.AccessDenied | ACCESS_DENIED | No permission for this app or record |
ErrorCode.MissingAppId | MISSING_APP_ID | Constructor called without appId and window.__HASP__ not set |
ErrorCode.NotFound | NOT_FOUND | Record, entity, or app not found |
ErrorCode.ReadOnlyRecord | READ_ONLY_RECORD | Record is read-only |
ErrorCode.ValidationFailed | VALIDATION_FAILED | Field validation error — check getFieldErrors() |
ErrorCode.StorageLimitReached | STORAGE_LIMIT_REACHED | Storage quota exceeded |
ErrorCode.RateLimited | RATE_LIMITED | Too many requests — retried automatically; throws if all retries exhausted |
ErrorCode.QueryTooComplex | QUERY_TOO_COMPLEX | Filter is too deeply nested or complex |
ErrorCode.Maintenance | MAINTENANCE | App is in maintenance mode |
ErrorCode.NetworkError | NETWORK_ERROR | Network unreachable |
ErrorCode.Unknown | UNKNOWN | Unexpected server error |
Validation Field Errors
Whenerror.code === ErrorCode.ValidationFailed, call error.getFieldErrors() to get a { fieldKey: 'message' } map of the first error per field:
401 Handling
On 401, the SDK callsonUnauthorized() (defaults to redirecting to /login) then throws HaspSDKError with ErrorCode.Unauthorized. Override onUnauthorized in the constructor to save draft state before redirecting.