Skip to content

Error Handling

The widget handles most errors internally and displays user-friendly messages. For deeper control, listen to the error events and react accordingly.

Emitted when the operation cannot continue. The widget shows an error screen.

widget.addEventListener('allfeat:failed', (e) => {
const { error, stage, code } = e.detail;
console.error(`[${stage}] ${error} (${code})`);
// Example: redirect on permission error
if (code === 'FORBIDDEN') {
window.location.href = '/access-denied';
}
});

Emitted for recoverable errors. The widget continues operating.

widget.addEventListener('allfeat:error', (e) => {
// Log for monitoring, no user action needed
sendToMonitoring({
stage: e.detail.stage,
error: e.detail.error,
code: e.detail.code,
});
});

allfeat:token-expired — Authentication Errors

Section titled “allfeat:token-expired — Authentication Errors”

See Authentication for the full token refresh flow.

CodeHTTPDescription
TOKEN_EXPIRED401JWT token has expired
INVALID_SITE_KEY401The site-key attribute is missing or doesn’t match the token
FORBIDDEN403Token doesn’t have permission for this action
NOT_FOUND404Resource not found (e.g., invalid access code)
CONFLICT409Duplicate or conflicting operation
RATE_LIMITED429Too many requests
BAD_REQUEST400Invalid request data
SERVER_ERROR5xxAllfeat API server error
NETWORK_ERRORNetwork connectivity issue
UPLOAD_ERRORFile upload to S3 failed
UNKNOWN_ERRORUnexpected error

The widget has built-in retry logic for transient failures:

ScenarioBehavior
File uploadUp to 3 retries with exponential backoff (1s, 2s, 4s)
Token expiryPauses and waits for a new token (60-second timeout)
Rate limiting (429)Up to 2 retries with backoff (1s, 2s, or Retry-After header)
Transaction pollingPolls every 3s with a 120-second timeout
Network errorsDisplayed to the user with an error screen

Call widget.reset() to clear the error state and return to the form:

widget.addEventListener('allfeat:failed', (e) => {
// Show a "Try again" button
retryButton.onclick = () => widget.reset();
});

Use getState() to inspect the widget’s current state for debugging:

const state = widget.getState();
console.log(state);
// {
// screen: 'FAILED',
// jobId: '...',
// transactionId: '...',
// atsId: null,
// accessCode: undefined
// }