Skip to content

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.

3 participants