You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Atul <at...@gmail.com> on 2015/03/05 10:30:34 UTC
Re: HandleFault in CXF Interceptors - tried possible options
Hi All,
I am facing a similar problem.
JAXRSValidationInINterceptor is throwing an exception in PRE_INVOKE phase. I
want to catch this exception and return a custom json response to the
client. I have created a custom interceptor which catches the exception ,
takes out the message . I have one exception mapper registered. I am using
that but its not working. No json content is going to the client. Please
help. I want to send JSON response to the client.
@Override
public void handleMessage(Message aInMessage) throws Fault
{
Exception e = aInMessage.getContent(Exception.class);
Fault f = (Fault)e;
if(f.getCause() instanceof ConstraintViolationException){
ConstraintViolationException exception =
(ConstraintViolationException)f.getCause();
String message =
exception.getConstraintViolations().iterator().next().getMessage();
XRouterError error = new XRouterError("401",message);
throw new OperationFailedException(error);
}
}
--
View this message in context: http://cxf.547215.n5.nabble.com/HandleFault-in-CXF-Interceptors-tried-possible-options-tp5735813p5754765.html
Sent from the cxf-user mailing list archive at Nabble.com.