Error Handling Methodology

20 views
Skip to first unread message

Kathir J

unread,
Jan 26, 2018, 11:30:51 AM1/26/18
to Getting started with Spring Framework
Below are the couple of example of error handling throughout the MVC application using spring or spring boot.

Please validate and let me know which is the correct approach. If none of them is correct, please suggest a right approach to follow for a MVC application which has controller, service, dao layer.

Example1: Controller throws exception whichever service layer throws it

https://github.com/aasthasmile/Spring-Boot-MVC-WebBasedApplication/blob/master/src/main/java/csulb/edu/aasthajain/controller/UserController.java

Example2: Catching exception in controller and throwing Status Object at last with error message

https://github.com/SurendraVidiyala/SpringRestCrud/blob/master/src/main/java/com/javacrud/controller/RestController.java

Example3: Creating exception in Controller and throwing the exception directly

https://github.com/khoubyari/spring-boot-rest-example/blob/master/src/main/java/com/khoubyari/example/api/rest/HotelController.java

Example4: Open Source project shopizer approach. catch exception in controller layer and sets the response status

https://github.com/shopizer-ecommerce/shopizer/blob/2.0.5/sm-shop/src/main/java/com/salesmanager/shop/controller/ReferenceController.java

jkathire...@gmail.com

unread,
Jan 26, 2018, 9:34:01 PM1/26/18
to Getting started with Spring Framework

Any suggestions or comments on how to resolve the below?
Reply all
Reply to author
Forward
0 new messages