Skip to content

Refactor exception handling in GlobalExceptionHandler and improve error#20

Open
ma-mirzaei wants to merge 2 commits into
developfrom
throw-exception-message
Open

Refactor exception handling in GlobalExceptionHandler and improve error#20
ma-mirzaei wants to merge 2 commits into
developfrom
throw-exception-message

Conversation

@ma-mirzaei

Copy link
Copy Markdown
Collaborator

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 GlobalExceptionHandler to write all error responses directly as JSON to the HTTP response (instead of returning ResponseEntity), ensuring consistent error format for all endpoints. Introduced a reusable writeErrorResponse method and switched to using HttpServletRequest/HttpServletResponse in exception handlers. [1] [2]

  • Updated error messages in VsumProjectBuildService to 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 VsumControllerErrorHandlingTest to 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 VsumProjectBuildServiceTest to assert the improved error messages, ensuring they contain both the descriptive message and the file counts. [1] [2]

Error context improvements:

  • Enhanced exception messages in VsumProjectBuildService to include the underlying exception message or reason for both IO and interruption errors, providing more context in error responses.…or messages in VsumProjectBuildService

@ma-mirzaei ma-mirzaei requested a review from arlange July 10, 2026 07:48
@ma-mirzaei ma-mirzaei self-assigned this Jul 10, 2026
@ma-mirzaei ma-mirzaei marked this pull request as ready for review July 10, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant