Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fatal error regarding exception handling #22

Merged
merged 1 commit into from
Sep 29, 2024
Merged

Conversation

MohanadKh03
Copy link
Collaborator

Removed @ControllerAdvice and used @RestControllerAdvice instead to be able to return APIResponse . The error was caused by not using @responsebody which basically wrapped our object into an HttpResponse

https://stackoverflow.com/questions/43124391/restcontrolleradvice-vs-controlleradvice

For future usage
Always use @ControllerAdvice with @responsebody when using a web service or just use @RestControllerAdvice and it will wrap the returned objects

@MohanadKh03 MohanadKh03 merged commit 69d704f into master Sep 29, 2024
3 checks passed
@Ahmad-AlDeeb
Copy link
Member

Ahmad-AlDeeb commented Sep 30, 2024

Nice 🔥

@Ahmad-AlDeeb
Copy link
Member

That's why this didn't happen in Mongo CRUD app even thought I was using general exception handler.
I was using the @RestControllerAdvice.
Thank you for figuring this out. ♥

@Ahmad-AlDeeb Ahmad-AlDeeb added the bug Something isn't working label Sep 30, 2024
@Ahmad-AlDeeb Ahmad-AlDeeb deleted the fix/exception branch September 30, 2024 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants