My question is similar to that raised at: 
http://restlet-discuss.1400322.n2.nabble.com/Sending-server-side-exceptions-error-codes-back-to-client-td7219795.html#a7229629
http://restlet-discuss.1400322.n2.nabble.com/Sending-server-side-exceptions-error-codes-back-to-client-td7219795.html#a7229629
, but since that has not been answered and this seems like a really basic
issue, I thought I would try posting again.

The question is simply this - how to get the details of an error/exception
that occurs on the Restlet server back to my Restlet client?  

I can see how to do this if my client were just a browser (I could construct
an HTML page on the server and return it).  

I thought that it would be pretty simple - set the Status code and Status
description.  But as the discussion above points out, that doesn't work.

I then thought that I could just set the Status code and send back a String
Representation of the error message.  But that doesn't work either.  In
particular, if I have:
  msg = "error xyz occurred";
  this.setStatus(Status.SERVER_ERROR_INTERNAL, msg);
  StringRepresentation result = new StringRepresentation(msg,
MediaType.TEXT_PLAIN);
  return result;
The client side call: 
  commitsRep = commitsResource.get();
Sets commitsRep == null (!).  Note: it is only set to null when the status
!= 200.  

So, I could set the status to 200 and then return the StringRepresentation
and then on the client, check to see if I have a StringRepresentation (which
would be an error) or some other type (which would be a success).

But surely there has got to be an easier way - what am I missing?  (I have
created my own StatusService on the server, I have thrown my own exception,
but no joy).

Thanks in advance for any hep - and thanks to Tim P for collecting all the
links in the thread above - but those weren't enough for me to work around
the problem.

RB

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Handling-exceptions-errors-when-using-Restlet-for-Client-and-Server-tp7578190.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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

Reply via email to