Hi Patrizio,
I’ve already replied to your question here: http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447 <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2413739> &dsMessageId=2413739 I hope that clarifies why you encounter this issue. 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 : Patrizio Munzi [mailto:[email protected]] Envoyé : vendredi 6 novembre 2009 17:33 À : [email protected] Objet : Re: problem returning a response status Up! Patrizio Munzi wrote: Jerome, never experienced this problem...?? Thanks Patrizio Munzi wrote: Hi everybody, I think there's a bug or at least something strange in ResourceException management. The getDescription method works only if I run my application in a stand-alone server. It instead doesn't work if I run in a servlet container (tomcat 5.5). I'm throwing the following exception server-side: ---------------------------------------------- } catch(Throwable e) { throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e.getMessage, e); } ---------------------------------------------- And here's my client code: ---------------------------------------------- try { Form form = new Form(); form.add("userId", userId); Representation userRepresentation = form.getWebRepresentation(); Request createUserRequest = new Request(Method.POST, createUrl); createUserRequest.setEntity(userRepresentation); Response response = client.handle(createUserRequest); resultStatus = response.getStatus(); } catch (Throwable t) { System.err.println("Exception in creating User: " + userId + ". Exception: " + t); } if (resultStatus.isSuccess()) { System.out.println("Created User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription()); } else { System.err.println("Error in creating User: " + userId + ". Status: " + resultStatus.getName() + " - Description: " + resultStatus.getDescription()); } ---------------------------------------------- II the application runs in a servlet container I get the following message client side: Error in creating User: TestUser. Status: Internal Server Error - Description: OK instead in a stand alone server I get the right description: Error in creating User: TestUser. Status: Internal Server Error - Description: Test Exception Has anyone got any idea if it's a bug or I'm doing something wrong???? Thanks Jerome Louvel wrote: Hi all, Regarding the propagation of exceptions on the client-side, I've got some plans there: "Add exception conversion to ConverterService" http://restlet.tigris.org/issues/show_bug.cgi?id=878 Best regards, Jerome Louvel -- Restlet ~ Founder and Lead developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com -----Message d'origine----- De : Thierry Boileau [mailto:[email protected]] Envoyé : vendredi 7 août 2009 18:02 À : [email protected] Objet : Re: problem returning a response status Hello Patrizio and Laurent, you're right Laurent. I notice also there is a lack of documentation about this that needs to be addressed. best regards, Thierry Boileau Hello, Patrizio Munzi a écrit : I'm trying to make work the following simple exception handling. I just want to return the status specified. The problem is that client side I cannot retrieve nothing, neither the exception or the exception message. I'm surely doing it wrongly, but I haven't find any written explanation on how managing exception. Could someone give me some hints to the right way??? I think you can do the following in your catch block : throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e); If it is not enough, try to extend StatusService class. More info in this thread http://restlet.markmail.org/message/ptesti33kkk5bksv?q=StatusService Hope it help. Regards, Laurent. Thanks --------------- @Post public void createUser(Representation entity) { try { // Parse the given representation and retrieve pairs of // "name=value" tokens. Form form = new Form(entity); String userId=form.getFirstValue("userId"); myApplication.createUser(userId); setStatus(Status.SUCCESS_CREATED, "Created User: " + userId); } catch(Throwable e) { e.printStackTrace(); setStatus(Status.SERVER_ERROR_INTERNAL, e, e.getMessage()); } } ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447 <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2381361> &dsMessageId=2381361 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447 <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2384451> &dsMessageId=2384451 -- Patrizio Munzi Product Specialist Viale Bruno Buozzi, 19 - 00197 Roma (Italy) tel: +39 06 4543 3540 fax: +39 06 4543 3587 mobile: +39 393 7195 164 mail: [email protected] web: http://www.eris4.com <http://www.eris4.com/> skype: eris4_munzi <skype:eris4_munzi?add> -- Patrizio Munzi Product Specialist Viale Bruno Buozzi, 19 - 00197 Roma (Italy) tel: +39 06 4543 3540 fax: +39 06 4543 3587 mobile: +39 393 7195 164 mail: [email protected] web: http://www.eris4.com <http://www.eris4.com/> skype: eris4_munzi <skype:eris4_munzi?add> -- Patrizio Munzi Product Specialist Viale Bruno Buozzi, 19 - 00197 Roma (Italy) tel: +39 06 4543 3540 fax: +39 06 4543 3587 mobile: +39 393 7195 164 mail: [email protected] web: http://www.eris4.com <http://www.eris4.com/> skype: eris4_munzi <skype:eris4_munzi?add> ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2416506
<<attachment: image001.gif>>

