Hi all, In V2.3 of Restlet API, we would like to introduce automatic conversion between Java throwable and HTTP status+body, working both ways (client and server sides).
The goal is to be able to write annotated Java interfaces including methods such as: @Get public MyBean represent() throws MyServerError, MyNotFoundError; Were the MyServerError and MyNotFoundError could be serialized as JSON/XML/eetc. error representations. For this you would annotate those Throwable classes with a @Status annotation such as: @Status("500") public class MyServerError implements Throwable{ ... } @Status("404") public class MyNotFoundError extends RuntimeException{ ... } A ClientResource wrapped proxy of MyResource including the represent() method would automatically deserialize the error JSON/XML/etc. into the proper Java exception. A ServerResource implementing the MyResource would be able to directly throw a MyServerError or a MyNotFoundError, setting its properties without having to worry about the HTTP status and error body. Content negotiation would even be able to take place. Would that be useful in your web APIs? Any design feed-back? Thanks, Jerome -- http://restlet.com @jlouvel <http://twitter.com/#!/jlouvel> ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3079971