Error Handling
Error Contract
Errors are returned as ErrorDetails from dependency com.friendly:ft-exceptions and produced by GlobalExceptionHandler (src/main/java/com/friendly/ftconfigsservice/utils/exception/GlobalExceptionHandler.java).
Shape (example):
{
"message": "Localized message to show to user",
"description": "Additional technical description",
"code": 123
}
HTTP status is derived from the error code inside ErrorDetails.
Localization
GlobalExceptionHandler#createErrorResponse localizes messages using:
-
service_errors*.properties(MessageSourceConfig#errorsMessageSource) -
Locale resolved from the current principal via
AuthUtils.getUserLocale()
Dry-run specific messages use separate bundle dry_run_messages*.properties via bean dryRunMessageSource.
Exception Classification (as implemented)
Handled explicitly:
-
FriendlyException→ returned as-is (localized when possible) -
ConstraintViolationException→ mapped toConfigsErrorCode.VALIDATION_ERRORwith joined violations -
DataIntegrityViolationException/SQLIntegrityConstraintViolationException→ mapped toFriendlyErrorCode.DATA_INTEGRITY_ERROR -
Client disconnects (
ClientAbortException, certainIOException) → mapped toFriendlyErrorCode.CLIENT_CONNECTION_CLOSED -
All other
Throwable→ mapped toFriendlyErrorCode.INTERNAL_ERROR