Error Handling

PulsePI provides standardized error responses to help you debug and handle issues in your application.

Error Response Format

When an error occurs, PulsePI returns a response with the following structure:

json
{
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message."
  }
}

Common Error Codes

Error CodeDescription
MODULE_NOT_FOUNDThe specified module does not exist
ACTION_NOT_FOUNDThe specified action does not exist in the module
INVALID_PARAMSThe parameters provided are invalid or missing required fields
UNAUTHORIZEDThe request lacks valid authentication credentials
FORBIDDENThe authenticated user does not have permission to perform the action
INTERNAL_ERRORAn unexpected error occurred on the server

Error Examples

Module Not Found

json
{
  "error": {
    "code": "MODULE_NOT_FOUND",
    "message": "Module 'xyz' not found."
  }
}

Invalid Parameters

json
{
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Missing required parameter 'email'."
  }
}

Error Handling Best Practices

  • Always check the response for an error property
  • Use the code for programmatic handling and the message for user display
  • Implement retry logic for transient errors (e.g., network issues)
  • Log detailed error information for debugging