Mam when you are recording the screen then audio is not recorded properly, please use the input source same as used in the starting of the video while recording whole content. Thanks for such an imformative discussion. 👍
Amazing How to return customised json response like below { "code": 1, "msg": "success", "data": [ { "id": 3, "name": { "fr":"person", "en":"engilsd" }, }, ] } also can I use this exception package to my others controller | or iim going to create a new exception handler foreach controller?
Thanks 😊 You need to create a new Response class and build the targeted response in that, and then use this Response class to send response back. For exception -> Please watch the full session as I have explained things in detail there. Yes, same exception package can be used, it depends on the project requirement. Same exception handler can be used to handle multiple exceptions, if similar handling is needed. For having different handling for different exceptions, separate handlers should be used.
In order to have graceful response from Spring Boot REST APIs in any scenario, exception handling is essential to implement. Hence, learning Spring Boot exception handling becomes mandatory to build a complete REST API Java project. REST APIs shall have a proper exception handling. In this session what, why and how to do custom exception handling in Spring Boot REST API is discussed in detail and demonstrated with CloudVendorAPI project. GitHub project link - github.com/thinkconstructive/rest-api-spring-boot-demo/tree/master Please watch the complete session to fully understand how to handle exceptions in Spring Boot REST API application and try all the demonstration along with the video. That will be very helpful. Enjoy learning the Spring Boot 😊 Kindly Subscribe, Like, Share & Ring the Notification Bell to remain connected with Think Constructive. Cheers, Esha
Why we should create the other 2 classes such as CloudExceptionHandler and CloudVendorException,if our requirements is to generate a custom Exception then only the Object of CloudVendorNotFoundException is sufficient!!
Your teaching level so amazing mam if you make daily spring boot lecture then I will definitely prompt your channel my friend's also learning spring boot
I'm really glad that I found your videos in regards to Spring Boot REST APIs it really helped me with my work task hehe, I will be waiting for a new REST API tutorial! Thanks alot!
Not sure about any sample project with full CRUD exception handling. In this video Exception handling is done for Get. In the similar manner, other operations can be implemented. Below is the GitHub link for the current project which is being build my current spring boot series of lectures, this has CRUD implemented; exception handling is done in Get operation currently. github.com/thinkconstructive/rest-api-spring-boot-demo/tree/master
I have tried to implement a custom exception handler when the list of vendors returned is empty. For that I used NO_CONTENT Http Status. I was able to get the http status as 204 no content but the response body is empty. can you please explain ?
Mam when I try to post or get in the postman i got "404 Not Found" error. I tried so many things but I still get the same error please tell me, Is there any way to solve this.
It helped a lot to clarify the topic. And you are not getting paid enough by the subscribers and likes. You explained it in a very neat and clean way. And i loved it ❣️ I have one query that we are getting null in the throwable... So how can we change the object and what could it be?
Thank you so much for your kind words. Really happy to know that you liked it and it helped you 😊 Please share with others too. Regarding throwable query - Are you not getting any cause in the Exception thrown? cloudVendorNotFoundException.getCause() -- In the demo code I have filled Exception Cause for throwable as argument.
Yes, noticed that cause is getting filled with null. You can fill exception object instead of exception.getCause() By doing this you can get complete stacktrace for the deatiled cause. Please do the changes in CloudVendorExceptionHandler.java file as follows - CloudVendorException cloudVendorException = new CloudVendorException( cloudVendorNotFoundException.getMessage(), cloudVendorNotFoundException, HttpStatus.NOT_FOUND );
Now understood, why ExceptionHandler is to be done in such a way. Clear the naming helps to identify. The many exception classes supports not to loose focus. You know exactly, where error message is to change.
Thanks so much for the video. I do not quite understand why CloudVendorException does not extend e.g. Exception or RuntimeException and why we do not use existing exception classes, such as org.springframework.web.client.HttpClientErrorException
I have been in the air trying to learn exception handling in springboot and finally I understood it. Thanks a lot for this clean, clear and precise video.
I think that a more clear and maintainable way to handle exceptions in one spot consists of a single handler that return a ResponseEntity with annotation ExceptionHandler(value= {Exception.class }) then you gonna implement logics based on checking what type of exception is ( instanceof ) and setting up various status codes into a utility class. Obviously at controller level you must throw the proper exceptions. Finally return the ResponseEntity with proper error responses. It's just my confortable way to manage all the system. Anyway what has done by the tutor is well done.