Difference between revisions of "GxRest/GxJRS/Responses"
From Gcube Wiki
Manuele.simi (Talk | contribs) (→What are Code Exceptions) |
Manuele.simi (Talk | contribs) (→What are Code Exceptions) |
||
Line 1: | Line 1: | ||
=== What are Code Exceptions === | === What are Code Exceptions === | ||
− | Code Exceptions model an approach to simplify and uniform the handling of exceptions (in the Java sense) within a RESTful or REST-like services. | + | Code Exceptions model an approach to simplify and uniform the handling of exceptions (in the Java sense) within a RESTful or REST-like services. Instead of creating separate classes for each exception type, the idea behind CodeException is to use a single, system-wide exception class. And make it extend WebApplicationException that in turn extends RuntimeException. |
+ | |||
+ | Major advantages of CodeException are: | ||
+ | * abstract over the response returned by a REST resource method | ||
+ | * provide a single (and self-documented) point where to declare error codes and messages returned by the webapp | ||
+ | * reduce the class count in a project (not to mention in a system) | ||
+ | * simplify the method declaration (RuntimeExceptions do not need to be declared) | ||
+ | * simplify the client code that manages only the error codes it is capable to handle | ||
+ | * remove the need to declare exceptions that sometimes aren’t going to be handled anyway. |
Revision as of 17:18, 4 January 2018
What are Code Exceptions
Code Exceptions model an approach to simplify and uniform the handling of exceptions (in the Java sense) within a RESTful or REST-like services. Instead of creating separate classes for each exception type, the idea behind CodeException is to use a single, system-wide exception class. And make it extend WebApplicationException that in turn extends RuntimeException.
Major advantages of CodeException are:
- abstract over the response returned by a REST resource method
- provide a single (and self-documented) point where to declare error codes and messages returned by the webapp
- reduce the class count in a project (not to mention in a system)
- simplify the method declaration (RuntimeExceptions do not need to be declared)
- simplify the client code that manages only the error codes it is capable to handle
- remove the need to declare exceptions that sometimes aren’t going to be handled anyway.