I had the same thought and updated SVN trunk a couple of minutes ago with
the exact same code ;)
 
Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~  <http://www.restlet.org/>
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  <http://www.noelios.com/>
http://www.noelios.com
 
  _____  

De : Tal Liron [mailto:[email protected]] 
Envoyé : vendredi 10 avril 2009 20:09
À : [email protected]
Objet : Re: ServerResource conditional mode


Pretty good... except what if the user throws a ResourceException with a
specific status code? I suggest something like this instead:

catch(InvocationTargetException e) {
    Throwable te = e.getTargetException();
    if (te instanceof ResourceException) {
       throw (ResourceException) te;
    } else {
       throw new ResourceException(te);
    }
}


Jerome Louvel wrote: 

Tal,
 
Thanks for this issue report.
 
I've changed the ServerResource behavior to rethrow checked exceptions of
annotated method as ResourceExceptions. This result in a 500 (Internal
server error) status being set by the ServerResource#handle() method.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~  <http://www.restlet.org/>
http://www.restlet.org
Noelios Technologies ~ Co-founder ~  <http://www.noelios.com/>
http://www.noelios.com
 

  _____  

De : Tal Liron [mailto:[email protected]] 
Envoyé : jeudi 9 avril 2009 00:06
À : [email protected]
Objet : Re: ServerResource conditional mode



Jerome, regarding exceptions caught --




You've implemented this only for when users override methods in
non-annotated mode. In annotated mode, exceptions are still not allowed.
This leads to different ways of doing things if you're in annotated or
non-annotated mode. Personally, I think that disallowing exceptions across
the board would result in better user code.




If you decide that you do want to handle exceptions for annotated handlers,
see doHandle(AnnotationInfo): you would need to get the reflected exception
via InvocationTargetException.getTargetException().




Whatever you decide, I recommend that the same allowances be made for both
annotated and non-annotated mode.





-Tal



Jerome Louvel wrote:


2) Exceptions caught
 
Currently (SVN trunk at least), the ResourceExceptions are caught and the
response status is updated accordingly. This is done in the
ServerResource#handle() method. Other exceptions will be caught upper in the
processing chain, by the StatusService for example. 
 
We do have some plans to extend the ConverterService in order to
automatically convert common exceptions into matching statuses, but I'm not
clear yet whether this is such a good idea (JAX-RS has this).

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1634003

Reply via email to