Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
jvx:communication:rest_exceptionhandling [2019/07/09 09:19]
admin
jvx:communication:rest_exceptionhandling [2019/07/09 10:32]
admin
Line 2: Line 2:
 ~~Title: REST Exception handling~~ ~~Title: REST Exception handling~~
  
-Our standard [[jvx:​common:​util:​rest|REST services]] come with standard exception handling. This means that all server-side exceptions send the http status code 400 (Bad Request) to the client. The implementation already checks some exception types and returns custom http status codes:+Our standard [[jvx:​common:​util:​rest|REST services]] come with standard exception handling. This means that all server-side exceptions ​will send the http status code 400 (Bad Request) to the client. The implementation already checks some exception types and returns custom http status codes:
  
 ^ Exception ^ http status ^ ^ Exception ^ http status ^
-|  UnknownObjectException | 404 (not found) | +|  UnknownObjectException | 404 (Not found) | 
-|  SecurityException | 403 (forbidden) | +|  SecurityException | 403 (Forbidden) | 
-|  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>​
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information