Skip to main content

Error Handling

All RMZ APIs use standard HTTP status codes and return structured JSON error responses.

Merchant API Error Format

Error responses from the Merchant API include an error: true field:
{
  "message": "Product not found: 999",
  "data": null,
  "api": "rmz.shawarma",
  "timestamp": 1699999999,
  "error": true
}

Storefront API Error Format

The Storefront API uses success: false:
{
  "success": false,
  "message": "Error message",
  "data": null
}

License API Error Format

The License API returns an error code string:
{
  "success": false,
  "error": "LICENSE_NOT_FOUND",
  "message": "License not found"
}

HTTP Status Codes

CodeMeaningWhen It Happens
200SuccessRequest completed successfully
201CreatedResource created (e.g., new order)
400Bad RequestValidation error or malformed request
401UnauthorizedMissing or invalid authentication
403ForbiddenAuthenticated but not authorized
404Not FoundResource does not exist
422Unprocessable EntityValidation failed
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error

Validation Errors

When request validation fails (400 or 422), the response includes field-level errors:
{
  "message": "The given data was invalid.",
  "errors": {
    "products": ["The products field is required."],
    "products.0.identifier": ["The products.0.identifier field is required."]
  }
}

Best Practices

Always check the HTTP status code first, then parse the response body for details.
  1. Check status codes — do not assume every response is successful
  2. Parse error messages — they contain actionable information
  3. Handle validation errors — iterate the errors object to display field-specific messages
  4. Log errors — include the timestamp and request details for debugging
  5. Handle network errors — timeouts and connection failures are not JSON responses