I have a spring boot application and i am looking for the best practices followed for exception handling. As I have read, we should only capture the exception that we understand and catching "Exception" object itself is not preferred. I need some clarifications on following points :
-
Shall the services below controller, throw the custom exception back after catching or shall they eat it up?
-
Rest controller will always catch up all the exception including "Exception" class itself, but somehow it should respond with user friendly failure message back.So ,how can we map backend exception to user friendly messages in rest controller? Shall the backend exception also have a custom string member which contains usr friendly information?or What is the preferred way to find user friendly message from given exception?
In case there are some other best practices, please let me know.
Aucun commentaire:
Enregistrer un commentaire