CoworkingBooking centralises all exception-to-HTTP-response mapping in a singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/devdavco/backend_1/llms.txt
Use this file to discover all available pages before exploring further.
@RestControllerAdvice class (RestExceptionHandler). When a handled exception is thrown anywhere in the request pipeline, the advice intercepts it and returns a structured JSON body with a consistent shape. Unhandled exceptions fall through to Spring Boot’s default error mechanism and return a 500 Internal Server Error. Understanding both paths — handled and unhandled — is essential for writing robust client code.
Error Response Format
All responses produced byRestExceptionHandler share the same JSON structure, defined by the Error record:
| Field | Type | Description |
|---|---|---|
type | String | A short machine-readable error code that identifies the category of the error. |
message | String | A human-readable description with context (e.g., the offending email address). |
The error code
email-alredy-exist is the literal string used in the source code (note the single r in “alredy”). Match this exact spelling when checking the type field in client logic.Known Error Codes
email-alredy-exist — 400 Bad Request
Exception class:
UsuarioAlreadyExistsExceptionTrigger: A POST /usuario/save request is made with an email address that is already registered in the usuarios table.Message format: "El usuario con el correo {email} ya existe"Validation errors (400 Bad Request)
TheCreateUsuarioRequest DTO carries Bean Validation annotations. When a request body fails these constraints, Spring returns a 400 Bad Request before the request even reaches service logic.
| Field | Annotation | Message (Spanish) |
|---|---|---|
nombre | @NotBlank | "El nombre es obligatorio" |
email | @NotBlank | "El correo es obligatorio" |
email | @Email | "El correo no es válido" |
Runtime / resource-not-found errors (500 Internal Server Error)
When aReserva, Espacio, or Usuario is looked up by ID and does not exist, the service layer throws a plain RuntimeException:
RuntimeException is not mapped by RestExceptionHandler, Spring Boot’s default handler returns 500 Internal Server Error with a generic error body rather than a 404 Not Found.
Returning
500 for a missing resource is a known practical limitation of the current implementation. In a REST-compliant design these cases would be mapped to 404 Not Found via a dedicated ResourceNotFoundException handler in RestExceptionHandler. For now, clients should treat a 500 response containing “no encontrada” in the message as a not-found condition.HTTP Status Codes
| Status Code | Scenario |
|---|---|
201 Created | Successful POST to any /save endpoint (e.g., POST /reserva/save). |
200 OK | Successful GET, DELETE, or PUT request. |
400 Bad Request | Bean Validation failure (@NotBlank, @Email) or duplicate-email condition. |
500 Internal Server Error | Resource not found (Reserva, Espacio, or Usuario with the given ID does not exist), or any other unhandled exception. |
Client Error Handling
The following pattern shows how to consume CoworkingBooking responses defensively — checking the HTTP status, parsing the structured error body when present, and distinguishing between handled errors (with atype code) and raw Spring Boot errors.
Error body reference
Machine-readable error code. Currently defined value:
"email-alredy-exist". Falls back to Spring Boot’s default "error" key for unhandled exceptions.Human-readable description of the error, often including the offending value (e.g., the email address or the resource ID that was not found).