Getting 500 error instead of 400 and 409
I am tryna handle the erros in the Api and Return the Exception according to the need as u can see in the code but i am not getting proper errors as i return them !
27 Replies
⌛
This post has been reserved for your question.
Hey @Danix! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Handling Both of them here
and getting 500 internal error for this why ? can someone help
is there any error in logs?
yehh the same 500 error with the same name exception that i have made !
can you debug it so you know on what ĺine its happening?
Hm yeh sure I will try
Is this declared in the same controller, an
@ControllerAdvice
or similar?
Can you show that?💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
I have made a different class for it and annotated it with the
@RestControllerAdvice
.. I will show u the code after reaching home
@dan1st | DanielIs the exception thrown from a RestController?
No from the service class method
..
what calls the service method?
A RestController? Another controller? Is the exception rethrown anywhere?
Can you show the complete stack trace?
A RestController as u can see in the code as well
yehh sure
I just see the endpoint method, not the whole controller class
I don't know whether it's an
@Controller
or @RestController
What's the package of your
RestControllerAdvice
?
What's the package of your main/application class?I meant of the class you annotated with
RestControllerAdvice
the GlobalExceptionHandler
Is that one actually instantiated and managed by Spring?
What's the package of that?
ohhh yes that's the problem
So your main class is in
com.ShelfSpace.ShelfSpace
This means Spring will only look at com.ShelfSpace.ShelfSpace
and subpackages
so it won't look at anything in com.ShelfSpace.advice
Also fix your package nameshmm
got it
ok thanks
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
buddy
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.