Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
jvx:communication:rest_exceptionhandling [2019/07/09 09:20] admin |
jvx:communication:rest_exceptionhandling [2019/07/09 10:32] admin |
||
---|---|---|---|
Line 9: | Line 9: | ||
| InvalidPasswordException | 401 (Unauthorized) | | | InvalidPasswordException | 401 (Unauthorized) | | ||
- | If you want custom status codes, it's possible to throw **RestServiceException**. This Exception class supports custom status codes and error messages. | + | If you want custom status codes, it's possible to throw **RestServiceException**. This Exception class supports custom status codes and error details. |
+ | <file java> | ||
+ | if (!isBookingAvailable()) | ||
+ | { | ||
+ | IBean details = new Bean(); | ||
+ | details.put("id", errorId); | ||
+ | details.put("message", "The booking feature isn't yet implemented!"); | ||
+ | |||
+ | throw new RestServiceException(501, details); | ||
+ | } | ||
+ | |||
+ | ... | ||
+ | </file> |