Error Handling
Global exception handler catches all unhandled exceptions and maps to a consistent JSON response format.
Overview
Every endpoint in the API guarantees a consistent wrapper format whether it succeeds or fails. Unhandled exceptions are automatically caught by a global middleware and mapped to an appropriate HTTP status code.
Standard Success Response
JSON
{
"isSuccess": true,
"data": { ... },
"message": "Operation completed successfully",
"error": null,
"errors": []
}Standard Error Response
JSON
{
"isSuccess": false,
"data": null,
"message": "",
"error": "Contact not found",
"errors": []
}Validation Errors (400)
JSON
{
"isSuccess": false,
"data": null,
"error": "Validation failed",
"errors": [
"Email is required",
"Password must be at least 8 characters"
]
}