Skip to content
Last updated

This page provides a comprehensive guide to handling errors returned by the PMS API. Each error includes an explanation, probable causes, and example code for resolving it in various programming languages.

Overview of Error Handling

The PMS API uses standard HTTP status codes to indicate the success or failure of API requests. The most common error categories are:

  • 201 (Success): A successful response with no body.
  • 400 (Bad Request): The request could not be understood or was missing required parameters.
  • 401 (Unauthorized): Authentication failed or the user does not have permissions.
  • 404 (Not Found): The requested resource could not be found.
  • 500 (Internal Server Error): An unexpected error occurred on the server.

Error Categories

1. Validation Errors (400 Bad Request)

Description: Occurs when the input parameters are invalid or missing.

Example Error Response:

 "status": 400,
  "detail": "Errors occurred while processing the request.",
  "errors": [
    {
      "name": "roomNumber",
      "reason": "RoomNumberConflict - The room you are trying to check in is already occupied with a guest from a different company. Please verify the room number and resubmit."
    }
  ]

Probable Causes:

  • Missing required fields in the request body.

How to Handle:

Validate input parameters before sending the request.

2. Authentication Errors (401 Unauthorized)

Description: Occurs when the API key or token is invalid, expired, or missing.

Example Error Response:

{
  "message": "Unauthorized"
}

Probable Causes:

  • Missing Authorization header.
  • Expired or incorrect API token.

How to Handle:

  1. Ensure the token is included in the Authorization header.
  2. Refresh the token if it has expired.

3. Internal Server Errors (500 Internal Server Error)

Description: Occurs when the API encounters an unexpected issue.

Example Error Response:

{    
  "errorCode": "INTERNAL_ERROR",    
  "message": "An unexpected error occurred. Please try again later." 
} 

Probable Causes:

  • Temporary server issue.
  • Unhandled exception on the server.

How to Handle:

  1. Retry the request after a short delay.
  2. Contact support if the issue persists.

General Best Practices for Error Handling

  • Log Errors: Always log error details to help with debugging.
  • Implement Retries: Use exponential backoff for retrying requests.
  • Graceful Failures: Provide fallback options or friendly error messages.
  • Documentation: Always refer to the latest API documentation for error codes and responses.