If you're using a recent release (works for me in 2.1-RC1) and you want to
control the status and error message in the simplest way, just ensure that
you translate all exceptions in your resource methods to ResourceExceptions
and use the standard status service:

@Post public Item addItem(Item item)
    try {
        // ... attempt to add item to store ...
    } catch (StorageSystemException ex) {
        // ... cleanup after failed attempt ...
        throw new
ResourceException(Status.SERVER_ERROR_INSUFFICIENT_STORAGE, "Storage system
exception", ex);
    }

Using a custom status service is necessary if you want to have custom error
representations.

--tim

On Tue, Jan 24, 2012 at 8:16 AM, D G <[email protected]> wrote:

> I have over ridden the getStatus method of the custom status service and
> set
> the status and returned it. I have tried various things but the status on
> the client side always show as Server Internal Error and no error message /
> description is available.  I've confirmed that the  getStatus method is
> invoked when StorageException is thrown on server side.
> The server runs under Apache Tomcat. I am using Annotations. Client is a a
> swing client using Restlet. Do I need to add some xml configuration some
> where ? On client side, I am retrieving the status from ClientResource.
> What
> am I missing here ? Please help.
>
>
>
> ErrorStatusService extends StatusService {
>
>       // StorageSystemException is an exception thrown by our application
>                public Status getStatus(Throwable throwable, Request req,
> Response resp){
>
>                logger.debug("ErrorStatusService.getStatus new");
>                Status status = null;
>        if (throwable instanceof ResourceException) {
>             return super.getStatus(throwable, req, resp);
>        }
>        else if (throwable instanceof StorageSystemException){
>                logger.error("ErrorStatusService.getStatus -
> StorageSystemException
> caught");
>                status = new
> Status(Status.SERVER_ERROR_INSUFFICIENT_STORAGE,
> "StorageSystemException");
>                resp.setStatus(new
> Status(Status.SERVER_ERROR_INSUFFICIENT_STORAGE,
> "StorageSystemException"));
>
>        }
>        return status;
> }
>
>
>
>
> --
> View this message in context:
> http://restlet-discuss.1400322.n2.nabble.com/Sending-server-side-exceptions-error-codes-back-to-client-tp7219795p7220293.html
> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>
> ------------------------------------------------------
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2910747
>

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

Reply via email to