How to return an exception in the result

27 views
Skip to first unread message

chunding xie

unread,
Aug 1, 2016, 4:26:15 AM8/1/16
to RestExpress
How to return an exception in the result

Todd Fredrich

unread,
Aug 3, 2016, 4:07:57 PM8/3/16
to RestExpress
Just throwing an exception will return an error in the result.

Throw one of these exceptions to return the corresponding HTTP status code: https://github.com/RestExpress/RestExpress/tree/master/core/src/main/java/org/restexpress/exception

Or extend ServiceException and set your own HTTP status in it.

If you want to change the format of what gets returned in the error response, implement ResponseWrapper (https://github.com/RestExpress/RestExpress/blob/master/core/src/main/java/org/restexpress/response/ResponseWrapper.java) --there are some examples in that package-- and use it in your SerializationProvider implementation.
Reply all
Reply to author
Forward
0 new messages