Package me.josephsf.jobportaljosephsfeir.exception
package me.josephsf.jobportaljosephsfeir.exception
Provides exception handling for the Job Portal application.
This package contains custom exception classes and a global exception handler that provide a structured approach to handling errors throughout the application. The exceptions defined here are used to create consistent, informative error responses for the REST API endpoints.
Key components in this package:
ResourceNotFoundException- Thrown when a requested resource (job, user, application, etc.) cannot be foundBadRequestException- Thrown when a client sends an invalid or malformed requestUnauthorizedException- Thrown when authentication fails or a user lacks permission for an actionGlobalExceptionHandler- Central exception handler that converts exceptions to appropriate HTTP responses
These exception classes are used throughout the service layer and controllers to provide clear, consistent error handling. The GlobalExceptionHandler ensures that all exceptions (including system exceptions) are translated into well-formed JSON responses with appropriate HTTP status codes.
Example usage:
public Job getJobById(String id) {
return jobRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Job", "id", id));
}
- Since:
- 2025-05-15
-
ClassDescriptionException thrown when a client sends a request with invalid parameters or data.Global exception handler that provides centralized exception handling across all controllers in the Job Portal application.Exception thrown when a requested resource cannot be found in the database or system.Exception thrown when a user attempts to access a resource without proper authentication or with insufficient permissions.