register rest exception mapper and convert there, for example see below:
note that the mapper works fine in REST only case, I actually ended up
building my own CustomFaultOutInterceptor such as this: public class
CustomFaultOutInterceptor extends AbstractPhaseInterceptor<Message>

public class RestExceptionMapper implements ExceptionMapper<Exception>
{
  private static Log logger = LogFactory.getLog(RestExceptionMapper.class);

  public Response toResponse(Exception exception)
{
    if (exception instanceof FooAuthException)
    {
        return
Response.status(Response.Status.FORBIDDEN).type(MediaType.APPLICATION_XML).
           entity(formatEntityMessage(exception, xmlHead)).build();
    }


Parimal Dhinoja wrote:
> 
> Hi all,
> 
> based on certain conditions, I need to set different HttpResponse Code
> back
> to client. I am thinking of throwing different type of Exception from
> service method based on condition met. and somewhere I need to catch these
> exception and need to set response code based on exception thrown.
> 
> Please let me know, how can I do this?
> 
> -- 
> Regards,
> Parimal
> "Nothing is stationary,Change is a part of Life"
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-handle-exceptions-in-JAx-rs-service-and-convert-it-to-Http--Response-code-based-on-type-of-Exception-tp26614920p26619747.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to