Skip to main content

Error Response Format

All API errors follow a consistent JSON structure:
boolean
required
Always false for error responses
string
required
Human-readable error message in Spanish
string
Optional error code for programmatic handling

HTTP Status Codes

The Viax API uses standard HTTP status codes:

Success Codes

OK
Request succeeded. Response includes requested data.
Created
Resource successfully created (not commonly used)

Client Error Codes

Bad Request
Invalid request parameters or malformed JSONCommon causes:
  • Missing required fields
  • Invalid data types
  • Malformed JSON
Unauthorized
Authentication failed or missing credentialsCommon causes:
  • Invalid email/password combination
  • User account does not exist
Forbidden
User lacks permission for the requested actionCommon causes:
  • Account is inactive or suspended
  • Insufficient permissions for admin endpoints
  • Driver not approved
Not Found
Requested resource does not existCommon causes:
  • User ID not found
  • Trip ID not found
  • Endpoint URL is incorrect

Server Error Codes

Internal Server Error
Unexpected server errorAction: Retry the request. If the error persists, contact support.
Service Unavailable
Service temporarily unavailableAction: Wait and retry with exponential backoff.

Exception Types

The Viax client SDK defines the following exception types:

ServerException

Thrown when the server returns an error response (HTTP 400, 500, etc.).
Example:

NetworkException

Thrown when there’s a network connectivity issue.
Common causes:
  • No internet connection
  • Request timeout
  • DNS resolution failure
  • Connection refused

NotFoundException

Thrown when a resource is not found (HTTP 404).
Example:

AuthException

Thrown for authentication failures (HTTP 401).
Example:

UnauthorizedException

Thrown for authorization failures (HTTP 403).

ValidationException

Thrown for data validation errors.

Common Error Scenarios

Invalid Credentials

Status Code: 401 Unauthorized

Email Already Registered

Status Code: 400 Bad Request

Missing Required Fields

Status Code: 400 Bad Request

Trip Not Found

Status Code: 404 Not Found

Driver Not Available

Status Code: 200 OK (success: false)

Network Timeout

Client-side exception, no HTTP response received.

Error Handling Best Practices

1

Check HTTP Status

Always check the HTTP status code first to determine the error category
2

Parse Error Response

Parse the JSON error response to get the specific error message
3

Handle Gracefully

Display user-friendly error messages and provide actionable next steps
4

Log for Debugging

Log errors for debugging, but never expose sensitive information
5

Retry When Appropriate

Implement retry logic for network errors and 5xx server errors

Retry Strategy

For transient errors (network issues, 503 errors), implement exponential backoff:
Do not retry these errors:
  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
Retry these errors:
  • Network timeouts
  • 500 Internal Server Error
  • 503 Service Unavailable

Timeout Configuration

The API has a default timeout of 30 seconds:
Ensure your client implements appropriate timeout handling:

Error Monitoring

The API includes error logging and crash reporting. Enable analytics in your configuration:

Support

If you encounter persistent errors or unexpected behavior:
  1. Check API status if monitoring is available
  2. Review the documentation for the specific endpoint
  3. Verify your request format matches the examples
  4. Contact technical support with:
    • Timestamp of the error
    • Request details (without sensitive data)
    • Full error response
    • Steps to reproduce