Hi Sean,

Code looks fine to me. I ran the code on my machine and got the custom
description as response body. I'm using Spring with restlet.

Here is the snippet that i had and is running fine on my machine.

*Status Service*


public class CustomStatusService extends StatusService {
        private static final Logger logger = LoggerFactory
                        .getLogger(ControllerStatusService.class);

        @Override
        public Status getStatus(Throwable throwable, Request request,
                        Response response) {
                if (throwable instanceof ResourceException) {
                        return super.getStatus(throwable, request, response);
                } else if (throwable instanceof ConnectException) {
                        logger
                                        .error(
                                                        "Error connecting to 
server. Check the stack trace for more
details.",
                                                        throwable);
                        return Status.CONNECTOR_ERROR_COMMUNICATION;
                } else {
                        // Unhandled exception. log the error and return 500 to 
the client
                        logger.error("Unhandled exception in resource 
handling", throwable);
                        return new Status(Status.SERVER_ERROR_INTERNAL, "custom 
errror");
                }
        }

        @Override
        public Representation getRepresentation(Status status, Request request,
                        Response response) {
                System.out
                                .println("getRepresentation(Status status, 
Request request, Response
response)");
                return new StringRepresentation(status.getDescription(),
                                MediaType.TEXT_PLAIN);

        }
}

*Application Spring bean*

<bean id="applicationRoot"
                class="com.mycompany.restlet.CustomWebApplication">
        <property name="statusService" ref="controllerStatusService"/>
</bean>

Thanks
Nitin

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/custom-exception-message-tp6969248p6973460.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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

Reply via email to