RE: Re: error trapping with ServerResource

2012-09-02 Thread Stephen More
My ServerResource now has: org.restlet.Request r = this.getRequest(); r.setEntity( CompanyId required, org.restlet.data.MediaType.TEXT_PLAIN ); throw new org.restlet.resource​.ResourceException( org.restlet.data.Sta​tus.CLIENT_ERROR_BAD​_REQUEST ); catch(

Re: error trapping with ServerResource

2012-09-02 Thread Paul Morris
Not exactly sure if this is what you're after but I would still set your message string in the setStatus method and and then use Status#getDescription in your catch block or wherever… -- Paul Morris, Software Developer Northwestern Memorial Physicians Group http://www.nmpg.com 773.469.4330 |

RE: Re: error trapping with ServerResource

2012-09-02 Thread Stephen More
Server side code: String errorMessage = CompanyId required; org.restlet.Request r = this.getRequest(); r.setEntity( errorMessage, org.restlet.data.MediaType.TEXT_PLAIN ); org.restlet.data.Status status = new org.restlet.data.Status( org.restlet.data.Status.CLIENT_ERROR_BAD_REQUEST, errorMessage

Re: Re: error trapping with ServerResource

2012-09-02 Thread Tim Peierls
Why set the request entity rather than the response entity? On Sun, Sep 2, 2012 at 9:46 AM, Stephen More stephen.m...@gmail.com wrote: Server side code: String errorMessage = CompanyId required; org.restlet.Request r = this.getRequest(); r.setEntity( errorMessage,

Re: error trapping with ServerResource

2012-09-02 Thread Paul Morris
Thanks Tim. Yes Stephen I missed that in your snippet... Use getResponse() Paul Morris On Sep 2, 2012, at 12:32 PM, Tim Peierls t...@peierls.netmailto:t...@peierls.net wrote: Why set the request entity rather than the response entity? On Sun, Sep 2, 2012 at 9:46 AM, Stephen More

SOLVED: RE: Re: error trapping with ServerResource

2012-09-02 Thread Stephen More
Working server side code: this.getResponse().setEntity( errorMessage, org.restlet.data.MediaType.TEXT_PLAIN ); org.restlet.data.Status status = new org.restlet.data.Status( org.restlet.data.Status.CLIENT_ERROR_BAD_REQUEST, errorMessage ); throw new org.restlet.resource.ResourceException( status

error trapping with ServerResource

2012-09-01 Thread Stephen More
I have a ServerResource that has: throw new org.restlet.resource.ResourceException( org.restlet.data.Status.CLIENT_ERROR_BAD_REQUEST, CompanyId required ); My client will: catch( org.restlet.resource.ResourceException re ) { org.restlet.data.Status status = re.getStatus(); log.error(

Re: error trapping with ServerResource

2012-09-01 Thread Paul Morris
void setEntityhttp://www.restlet.org/documentation/2.0/jse/api/org/restlet/Message.html#setEntity(java.lang.String,%20org.restlet.data.MediaType)(Stringhttp://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html?is-external=true value,