Hello,
I'm using restlet 2.0-SNAPSHOT with the jee and the jaxb extensions.
My question pertains to how one must handle exceptions with the restlet API.
Consider the following scenario:-
1/ A simple domain object 'Contact'.
2/ A Server Resource 'ContactResource' with a method "public Contact
getContact()" and appropriate implementation.
3/ The router is setup to serve Contact's at "/contacts/{id}'.
On the client side, the effective code being used is:-
ClientResource cr = new ClientResource(base + "/contacts/1");
ContactResource resource = cr.wrap(ContactResource.class);
Contact contact = resource.getContact();
The question is, say I tried retrieving "/contacts/2" which does not exist in
the contact list, how can I get restlet to throw a particular type of exception
(even a subclass of ResourceException) and propogate it to the client? Is this
even possible?
If I need to use StatusService, how should I use it to return an appropriate
Representation given the way the client is invoking the interface method
directly and expects a Contact in return?
I even tried setting the Status on the server side but was unable to get the
same contents on the client side. Is this a bug within the 2.0-SNAPSHOT
codebase?
Also, when in my custom StatusService, I notice that only getRepresentation is
invoked and not getStatus. Moreover, within getRepresentation, the status still
does not hold the Throwable cause that I set when I couldn't find the contact.
I'm not sure I'm doing this right and hence would appreciate some help.
Is there an example anywhere that touches on this topic? The documentation is
really sparse and not very navigable.
Thanks!
- Dinesh.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2624846