Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Rubick65/calenderyBack/llms.txt

Use this file to discover all available pages before exploring further.

Overview

CalenderyBack uses a centralised @RestControllerAdvice (ApiExceptionHandler) to intercept all application exceptions and return a consistent JSON error envelope. Every error response — whether a validation failure, a missing resource, or a business rule violation — shares the same ErrorMessage structure.

The ErrorMessage Schema

// com.rubenmartin.calenderyback.common.exceptions.ErrorMessage
public class ErrorMessage {
    private String message;       // Human-readable description of the error
    private String exception;     // Simple class name of the thrown exception
    private String path;          // Request URI that triggered the error
    private Map<String, String> errors; // Field-level validation errors (400 only)
}
FieldTypeAlways presentDescription
messageStringThe exception’s message, describing what went wrong
exceptionStringSimple class name of the Java exception (e.g. "UserNotFoundException")
pathStringThe request URI that triggered the error (e.g. "/api/users/app/getSearchUsers")
errorsMap<String, String>Key-value map of field name → validation message. Empty {} for non-validation errors.
When multiple exceptions share the same HTTP status code, use the exception field to distinguish them programmatically. For example, both UserNotFoundException and UserAlreadyExistException return 404, but their exception values are different — so you can branch your error-handling logic on that field without inspecting the message string.

Example Error Responses

404 Not Found — Resource Missing

{
  "message": "User not found with id: 999",
  "exception": "UserNotFoundException",
  "path": "/api/users/999",
  "errors": {}
}

400 Bad Request — Validation Failure

When a request body fails Jakarta Bean Validation (@Valid), each failing field is listed in the errors map:
{
  "message": "Validation failed for argument...",
  "exception": "MethodArgumentNotValidException",
  "path": "/api/users/auth/register",
  "errors": {
    "email": "must be a well-formed email address",
    "nombre": "must not be blank"
  }
}

Complete Error Reference

Several exceptions that represent logically different situations — such as a resource genuinely not existing (UserNotFoundException) and a resource already existing (UserAlreadyExistException) — are both mapped to 404 Not Found. This is a quirk of the current implementation rather than a REST best-practice recommendation (a strict REST API would return 409 Conflict for duplicates). Always inspect the exception field to understand the actual cause.
Exception ClassHTTP StatusTrigger Condition
MethodArgumentNotValidException400 Bad RequestA @Valid-annotated request body fails Jakarta Bean Validation; field-level errors are populated in the errors map
UserNotFoundException404 Not FoundNo user exists for the provided ID or email
UserAlreadyExistException404 Not FoundAttempting to register with an email address that is already in use
RolNotFoundException404 Not FoundThe requested role does not exist in the database
TokenNotFoundException404 Not FoundNo verification token matches the provided token string
ExpiredVerificationTokenException401 UnauthorizedThe provided email-verification token has passed its expiry time
DisabledException401 UnauthorizedThe account exists but has not yet been verified / enabled
UserDisableAccountException404 Not FoundThe account has been explicitly disabled by an admin
MessageNotFoundException404 Not FoundNo message exists for the provided message ID
ChatNotFoundException404 Not FoundNo chat exists for the provided chat ID
PublicationNotFoundException404 Not FoundNo publication exists for the provided publication ID
FollowerNotFoundException404 Not FoundThe requested follower relation record does not exist
PublicationLikeNotFoundedException404 Not FoundNo like record exists for the given publication and user combination
UserNotFollowingException406 Not AcceptableAttempting to unfollow a user that the authenticated user is not currently following
PublicKeyNotFoundException404 Not FoundThe requested user has not yet set a public encryption key
MessageStateNoUpdatedException406 Not AcceptableA message read-state update could not be applied (e.g. invalid state transition)
PublicKeyNotCoincidentException406 Not AcceptableThe provided public key does not match the key stored for that user
CommentNotDeletedException406 Not AcceptableAttempting to delete a comment that belongs to a different user (author mismatch)

Build docs developers (and LLMs) love