Hi Sergei, > -----Original Message----- > From: Sergey Beryozkin [mailto:[email protected]] > Sent: Dienstag, 29. Januar 2013 14:16 > To: [email protected] > Subject: Re: [CXF.REST] javax.ws.rs exception throwing from > ExceptionMapper > > Hi Andrei > On 29/01/13 12:51, Andrei Shakirin wrote: > > Hi, > > > > Would like to discuss the following: > > CXF Rest service implementation processes javax.ws.rs > (NotFoaundException, BadRequestException) exceptions correctly. > > But if these exception are thrown form exception mapper, client always > receive InternalServerError exception. > > > > Is this behaviour specified by JAX-RS? > > I'm actually not seeing anything specific in the text, but I think at the > moment > that CXF is correct, because otherwise the question is how to map these > rethrown exceptions and we can have an infinity loop - something the spec > talks about, for example, an exception mapper sets a Response entity - next > MessageBodyWriter throws the exception again - this 500, so I think it is 500 > in this case too >
Hmm ... is it possible not to map exceptions thrown by ExceptionMapper again to avoid loops? Is there any possibility to distinguish them? > > I find convenient in some cases just to re-throw javax.ws.rs exceptions > from mapper and not build Response manually. > > > Sure, in this case it is easy :-), all WebApplicationException instances have > getResponse() method - so simply use exception.getResponse() - it will have > a proper status set, etc.. Sure, if response is set. But if it is null? Mapper must build response manually, set correct response code - not a big deal, but anyway ... Regards, Andrei. > > HTH, Sergey > > > WDYT? > > > > Regards, > > Andrei. > > > > > >
