Hi Andrei -
Having said all of this, I've open an improvement request to get the
runtime recognizing WAE exceptions thrown from the mappers - I don't
know if it will be accepted or not, lets see...
Thanks
Sergey
On 29/01/13 15:13, Sergey Beryozkin wrote:
Just a bit more info, when a code throws something like "new
NotFoundException()", NotFoundException implementation will initialize
Response to contain 404, etc.
Cheers, Sergey
On 29/01/13 13:49, Sergey Beryozkin wrote:
Hi Andrei
On 29/01/13 13:44, Andrei Shakirin wrote:
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?
The only thing the runtime can do is to catch the exception, check if it
is an instance of WebApplicationException and if yes - getResponse on
it, which is exactly what the mapper can do; and I think if we did it it
would probably be not-portable...
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 ...
For WebApplicationExceptions it is always set,
as for the custom non WAE-exceptions - only the mappers know how to map
them to anything but 500 :-)
Cheers, Sergey
Regards,
Andrei.
HTH, Sergey
WDYT?
Regards,
Andrei.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com