Refactor exception handling in GlobalExceptionHandler and improve error#20
Open
ma-mirzaei wants to merge 2 commits into
Open
Refactor exception handling in GlobalExceptionHandler and improve error#20ma-mirzaei wants to merge 2 commits into
ma-mirzaei wants to merge 2 commits into
Conversation
…or messages in VsumProjectBuildService
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.
This pull request refactors and improves error handling in the VSUM project setup service, making error responses more consistent, user-friendly, and testable. The main changes include switching to a custom JSON error response for all exceptions, enhancing error messages for input validation, and adding dedicated tests for error handling.
Error handling and response improvements:
Refactored
GlobalExceptionHandlerto write all error responses directly as JSON to the HTTP response (instead of returningResponseEntity), ensuring consistent error format for all endpoints. Introduced a reusablewriteErrorResponsemethod and switched to usingHttpServletRequest/HttpServletResponsein exception handlers. [1] [2]Updated error messages in
VsumProjectBuildServiceto be more descriptive, including the actual counts of uploaded files when metamodel and genmodel file counts do not match.Testing improvements:
Added a new test class
VsumControllerErrorHandlingTestto verify that the API returns a proper JSON error response (with correct status and message) when a client requests a ZIP but an input validation error occurs.Updated existing tests in
VsumProjectBuildServiceTestto assert the improved error messages, ensuring they contain both the descriptive message and the file counts. [1] [2]Error context improvements:
VsumProjectBuildServiceto include the underlying exception message or reason for both IO and interruption errors, providing more context in error responses.…or messages in VsumProjectBuildService