Repository navigation
feat(api): standardise exception responses using RFC 7807 Problem Det… - #340
Conversation
…ails - Enable spring.mvc.problemdetails.enabled in application profiles. - Add type, title, detail, and instance attributes to ApiResponse. - Refactor global and payment exception handlers to dynamically return Spring's native ProblemDetail structure - when Accept: application/problem+json is requested. - Add ProblemDetailsIntegrationTest to assert RFC 7807 structure mapping and default JSON envelope compatibility. Signed-off-by: aniebietafia <aniebietafia87@gmail.com>
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (24)
📝 WalkthroughWalkthroughThis PR introduces a ChangesPaginated Response Standardization
Problem Details Error Response Support
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller
participant ResponseBuilderService
participant PagedResponse
Client->>Controller: GET paginated endpoint
Controller->>Controller: fetch Page<Entity> from repository
Controller->>ResponseBuilderService: buildPagedResponse(page, status, message)
ResponseBuilderService->>PagedResponse: fromPage(page)
PagedResponse-->>ResponseBuilderService: PagedResponse<T>
ResponseBuilderService-->>Controller: ApiResponse<PagedResponse<T>>
Controller-->>Client: ResponseEntity<ApiResponse<PagedResponse<T>>>
sequenceDiagram
participant Client
participant ExceptionHandler
participant RequestContextHolder
Client->>ExceptionHandler: request with Accept header
ExceptionHandler->>RequestContextHolder: read current request
ExceptionHandler->>ExceptionHandler: shouldReturnProblemDetail()
alt Accept includes application/problem+json
ExceptionHandler->>ExceptionHandler: build ProblemDetail (type, title, instance, errorCode, traceId)
ExceptionHandler-->>Client: ResponseEntity<Object> (application/problem+json)
else default JSON
ExceptionHandler->>ExceptionHandler: build ApiResponse<Void> (detail, path, traceId)
ExceptionHandler-->>Client: ResponseEntity<Object> (application/json)
end
Related Issues: Not specified in provided information. Related PRs: Not specified in provided information. Suggested labels: enhancement, api, breaking-change Suggested reviewers: Not specified in provided information. 🐰 A hop, a skip, a paged reply, Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
|
|
…ails
Summary by CodeRabbit
New Features
Bug Fixes
Tests