-
-
Notifications
You must be signed in to change notification settings - Fork 1
Error Codes
This document provides a comprehensive list of all error codes returned by the Bolt Driver API.
Description: Maximum number of SMS authentication attempts reached in 24 hours.
Common Causes:
- Too many login attempts in a short period
- Multiple failed authentication attempts
Resolution:
- Wait 24 hours before trying SMS authentication again
- Use magic link authentication as an alternative
Example:
try {
await api.startAuthentication(...);
} catch (error) {
if (error.code === 299) {
// Switch to magic link
await api.sendMagicLink(email);
}
}Description: The provided phone number format is invalid.
Common Causes:
- Missing country code
- Invalid number format
- Non-existent country code
Resolution:
- Include full international format (e.g., +48123456789)
- Verify country code is correct
- Remove spaces and special characters
Description: Server-side database error occurred.
Common Causes:
- Temporary server issues
- Database maintenance
Resolution:
- Retry the request after a few seconds
- Contact support if issue persists
Description: The SMS verification code is incorrect or expired.
Common Causes:
- Typed wrong code
- Code expired (usually after 5 minutes)
- Using code from previous attempt
Resolution:
- Double-check the code
- Request a new code if expired
- Ensure using the latest SMS received
Description: Authentication failed or access denied.
Common Causes:
- Invalid credentials
- Account suspended
- Token expired
Resolution:
- Verify credentials are correct
- Re-authenticate if token expired
- Contact support for account issues
Description: Request requires authentication or token is invalid.
Common Causes:
- Missing authentication token
- Expired access token
- Invalid token format
Resolution:
// Handle globally
if (error.response?.status === 401) {
// Refresh token or re-authenticate
await api.getAccessToken();
// Retry request
}Description: Request parameters are invalid.
Common Causes:
- Missing required parameters
- Invalid parameter values
- Wrong data types
Resolution:
- Check API documentation for required parameters
- Validate input data before sending
- Review parameter types and formats
Description: Requested resource not found.
Common Causes:
- Invalid order ID
- Ride doesn't exist
- Wrong endpoint URL
Resolution:
- Verify resource ID is correct
- Check if resource still exists
- Ensure using correct API endpoint
Description: Too many requests sent in a given time period.
Common Causes:
- Polling too frequently
- Batch operations too fast
- Not respecting polling intervals
Resolution:
// Respect polling intervals
const state = await api.getDriverState(gps);
setTimeout(() => {
// Next request
}, state.next_polling_in_sec * 1000);Description: Server encountered an unexpected error.
Common Causes:
- Server malfunction
- Temporary service disruption
Resolution:
- Retry with exponential backoff
- Report persistent issues
Description: Operation requires driver to be online.
Common Causes:
- Trying to accept rides while offline
- Accessing features requiring online status
Resolution:
- Set driver status to online first
- Check driver state before operations
Description: Ride has already been accepted by another driver.
Common Causes:
- Slow response to ride request
- High demand area
Resolution:
- React faster to ride requests
- Move to less competitive areas
Description: GPS location is invalid or outside service area.
Common Causes:
- GPS accuracy too low
- Outside Bolt service area
- Invalid coordinates
Resolution:
// Ensure valid GPS data
const gpsInfo = {
latitude: 52.237049,
longitude: 21.017532,
accuracy: 10, // Must be reasonable
timestamp: Date.now()
};Description: Driver has outstanding payments or fees.
Common Causes:
- Unpaid commission
- Outstanding fines
- Negative balance
Resolution:
- Check balance in earnings section
- Make required payments
- Contact support for payment plans
Description: Network connection failed.
Common Causes:
- No internet connection
- Request timeout
- DNS resolution failure
Resolution:
// Implement retry logic
async function withRetry(fn, retries = 3) {
for (let i = 0; i < retries; i++) {
try {
return await fn();
} catch (error) {
if (error.code === 0 && i < retries - 1) {
await new Promise(r => setTimeout(r, 1000 * (i + 1)));
continue;
}
throw error;
}
}
}class ErrorHandler {
static handle(error: BoltApiError): void {
switch (error.code) {
case 299:
this.handleSmsLimit();
break;
case 401:
this.handleUnauthorized();
break;
case 429:
this.handleRateLimit();
break;
default:
this.handleGeneric(error);
}
}
static handleSmsLimit(): void {
// Show magic link option
console.log('SMS limit reached. Please use email authentication.');
}
static handleUnauthorized(): void {
// Trigger re-authentication
console.log('Session expired. Please login again.');
}
static handleRateLimit(): void {
// Implement backoff
console.log('Too many requests. Please wait.');
}
}class RetryStrategy {
static shouldRetry(error: BoltApiError): boolean {
const retryableCodes = [0, 301, 429, 500];
return retryableCodes.includes(error.code);
}
static getDelay(attempt: number, error: BoltApiError): number {
if (error.code === 429) {
// Rate limit - wait longer
return 60000; // 1 minute
}
// Exponential backoff
return Math.min(1000 * Math.pow(2, attempt), 30000);
}
}class ErrorMessages {
static getUserMessage(error: BoltApiError): string {
const messages: Record<number, string> = {
299: 'Too many login attempts. Please try email authentication.',
300: 'Please enter a valid phone number with country code.',
301: 'Server is temporarily unavailable. Please try again.',
302: 'Invalid verification code. Please check and try again.',
401: 'Your session has expired. Please login again.',
429: 'Too many requests. Please wait a moment.',
503: 'Access denied. Please check your credentials.',
};
return messages[error.code] || 'An unexpected error occurred.';
}
}// Configure logging for better error tracking
const api = new BoltDriverAPI(
deviceInfo,
authConfig,
{},
null,
{
level: 'error',
logRequests: true,
logResponses: true
}
);
// Custom error logging
api.getLogger().error('Custom error', {
code: error.code,
message: error.message,
stack: error.stack,
timestamp: new Date().toISOString()
});Problem: Keep getting 401 errors even after authentication.
Solution:
// Clear old tokens
api.clearAuthentication();
// Fresh authentication
await api.startAuthentication(...);Problem: Random network errors in good connection.
Solution:
// Increase timeout
const api = new BoltDriverAPI(
deviceInfo,
authConfig,
{
timeout: 60000, // 60 seconds
retries: 5
}
);Problem: Frequently hitting rate limits.
Solution:
// Implement request queue
class RequestQueue {
private queue: Array<() => Promise<any>> = [];
private processing = false;
private minDelay = 1000; // 1 second between requests
async add<T>(request: () => Promise<T>): Promise<T> {
return new Promise((resolve, reject) => {
this.queue.push(async () => {
try {
const result = await request();
resolve(result);
} catch (error) {
reject(error);
}
});
if (!this.processing) {
this.process();
}
});
}
private async process(): Promise<void> {
this.processing = true;
while (this.queue.length > 0) {
const request = this.queue.shift();
if (request) {
await request();
await new Promise(r => setTimeout(r, this.minDelay));
}
}
this.processing = false;
}
}If you encounter errors not listed here:
- Check the FAQ
- Search GitHub Issues
- Enable debug logging for more details
- Contact support with error details and logs