feat(EM-46): Centralized Error Handling and Exception Patterns#57
Open
devin-ai-integration[bot] wants to merge 1 commit intofeat/microservices-migration-v2from
Open
Conversation
- Define exception hierarchy: BaseException, BusinessException, ResourceNotFoundException, ValidationException, ConflictException, UnauthorizedException, ForbiddenException, ServiceUnavailableException, UpstreamServiceException - Create @RestControllerAdvice GlobalExceptionHandler with standard HTTP status mapping - Add CorrelationIdFilter for X-Correlation-ID propagation via MDC - Enhance ErrorResponse DTO with correlationId field - Register auto-configuration for handler and filter - Add comprehensive tests (69 tests passing) - Update error-handling documentation with usage examples Co-Authored-By: Alex Baker <alexandercommander453@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(EM-46): Centralized Error Handling and Exception Patterns
Summary
Extends
libs/ftgo-api-standards/with a shared error handling framework:BaseExceptionwith 8 concrete subclasses (BusinessException,ResourceNotFoundException,ValidationException,ConflictException,UnauthorizedException,ForbiddenException,ServiceUnavailableException,UpstreamServiceException) — each carrying anerrorCodeandhttpStatus.@RestControllerAdvicehandler:GlobalExceptionHandlermaps all custom exceptions plus common Spring MVC exceptions to standardizedErrorResponseDTOs.CorrelationIdFilter(servlet filter,HIGHEST_PRECEDENCE) extracts or generates a UUID fromX-Correlation-IDheader, stores it in SLF4J MDC, and includes it in every error response.FtgoErrorHandlingAutoConfigurationregisters the handler + filter with@ConditionalOnMissingBeanso services can override.ErrorResponseenhanced with acorrelationIdfield (backward-compatible).docs/api-standards/error-handling.md.Review & Testing Checklist for Human
slf4j-api:2.0.12dependency was added, but Spring Boot 3.2.5's BOM managesslf4j-api:2.0.13. Verify Gradle resolves this without a downgrade or remove the explicit declaration and rely on the transitive version.handler.handleBaseException()), not through Spring's@ExceptionHandlerdispatch. Confirm that Spring correctly routesValidationException(which extendsBaseException) tohandleValidationExceptionand nothandleBaseException. Consider adding a@WebMvcTestintegration test.spring-boot-starter-webpromoted toapiscope: This means all downstream consumers offtgo-api-standardsnow transitively pull in the full web starter. Verify this is acceptable for all consuming modules.mockito-coredependency: Added tobuild.gradlebut no test uses Mockito. Minor, but worth cleaning up.Recommended test plan: Wire up a minimal
@WebMvcTestwith a test controller that throws each exception type and verify the HTTP responses end-to-end, including correlation ID propagation via headers.Notes
settings.gradleper task constraints