How can I provide a custom error handler for a service?
Case Study: I have this service which persists the Operation passed either by
xml or by json. The problem is, when a malformed structure is passed, the
server it returns a predefined error message.
@POST
@Consumes({"text/xml", "application/json"})
public void save(Operation operation) {
operationDAO.save(operation);
}
Where should I handle the exceptions to provide a different status code other
than 500 and custom messages.
The FAQ tells "If you want a different status when an exception is thrown, you
have to catch it manually at a lower level (inside the handle(Call) or
handleGet|Post|etc. method of your intermediary Restlet)", but following the
pattern from the jaxrs extension example I have a Resource
(OperationServerResource), an Application config (OperationApplication) and the
Server (for now it only has the OperationApplication being attached, but later
there is going to be a lot of applications). In this pattern, the only place
where I can override the handle() is at the server, but by doing this I'll
handle all specific exceptions from all bussiness classes (as Operation) at the
same place ;/.
Is there a different pattern I could use or a different way to handle the
exceptions than ovewriting the component's handle in the server?
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2731311