Questions tagged [exceptionmapper]

JAX-RS contract for a provider that maps Java exceptions to Response.

From Javadoc

public interface ExceptionMapper<E extends Throwable>

Contract for a provider that maps Java exceptions to Response.

Providers implementing ExceptionMapper contract must be either programmatically registered in a JAX-RS runtime or must be annotated with @Provider annotation to be automatically discovered by the JAX-RS runtime during a provider scanning phase.

46 questions
2
votes
1 answer

ExceptionMapper not work in grizzly

Sorry for my poor English. I'm using grizzly and jersey to build a web application. And I implement like this ErrorModel errorModel = new ErrorModel("1", "1", "1"); WebApplicationException applicationException =…
1
vote
0 answers

ExceptionMapper will not invoked when JAX-RS exceptions thrown in Quarkus dev mode

I am working on a Quarkus (2.7.1)  application and facing with a problem which I cannot understand the reason.I write a class that implement ExceptionMapper interface to catch RuntimeException and I expect that any unhandled exception will be caught…
khesam109
  • 510
  • 9
  • 16
1
vote
0 answers

JAX-RS ExceptionMapper not catch javax.validation.ConstraintViolationException

I have started using javax.validation's @Valid annotation to validate data arriving at my REST endpoints. This is working as expected and throwing applicable exceptions: Caused by: javax.validation.ConstraintViolationException: Validation failed for…
Bend
  • 304
  • 1
  • 2
  • 15
1
vote
0 answers

RestEasy ExceptionMapper is unable to map exception thrown at filter level

The ExceptionMapper implementation works fine for the exceptions thrown at controller level of my code. However there are some authentication filter being executed before and after the api call. Exception thrown at filter level is not being mapped…
Kroor Singh
  • 255
  • 2
  • 7
1
vote
2 answers

Custom HTTP reason phrase using ExceptionMapper

I have defined the following Exception Mapper to handle the custom HttpCustomException package com.myapp.apis; import com.myapp.apis.model.HttpCustomException; import com.myapp.apis.model.HttpCustomExceptionStatusType; import…
Hashken
  • 4,396
  • 7
  • 35
  • 51
1
vote
0 answers

Javax Exception Mapper just throws 500

I have a REST interface implemented with javax to login a user. @Path("/login") @GET @Produces(MediaType.APPLICATION_JSON) public UserId login(@QueryParam("email") String email, @QueryParam("password") String password) throws…
Chinaedu Onwukwe
  • 437
  • 1
  • 7
  • 20
1
vote
1 answer

Jersey ExceptionMapper, rely on another ExceptionMapper

I have an ExceptionMapper which is part of a generic common library: @Provider public class GenericExceptionMapper implements ExceptionMapper { ... } Now, in my specific project, I have my own ExceptionMapper: @Provider public…
Twain Dres
  • 13
  • 2
1
vote
1 answer

Dropwizard deserialising custom exception as JSON?

I have created a new exception class in my Dropwizard service that extends BadRequestException. public class CustomBadRequestException extends BadRequestException { private static final long serialVersionUID = 1L; private…
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
1
vote
1 answer

Jersey invoking sub resource wrongly

I am learning RESTful web services using JAX-RS. I have a MessageResource and a sub resource CommentResource. In my MessageResource I mapped comment sub resource with test method, which I commented in the MessageResource class because I don't want…
Narendra Jaggi
  • 1,297
  • 11
  • 33
1
vote
2 answers

Spring JsonExceptionMapper ExceptionMapper handling.

I am getting following error in my weblogic console when i am starting my server. SEVERE: Missing dependency for constructor public com.test.mine.exception.JsonExceptionMapper(java.lang.String,com.fasterxml.jackson.core.JsonLocation) at parameter…
1
vote
1 answer

How can i preserve the request headers in error response prepared through JAX-RS ( Apache-CXF implementation) ExceptionMapper

I am implementing JAX-RS using apache CXF. I have created an ExceptionMapper to handle bad requests like this: public class ClientErrorExceptionMapper implements ExceptionMapper { @Override public Response…
ishan
  • 1,202
  • 5
  • 24
  • 44
1
vote
0 answers

Have an ExceptionMapper return different response types depending on where the exception comes from

I have an ExceptionMapper called NotFoundExceptionMapper that I need to behave like this: @Provider public class NotFoundExceptionMapper implements ExceptionMapper { public Response toResponse(NotFoundException e) { …
Certainly
  • 107
  • 1
  • 9
0
votes
0 answers

Injection issue for exception mapper with abstract parent (Quarkus REST client)

I'm trying to create an ExceptionMapper with an abstract parent class and some injected fields. Here is the part of code, simplified: @Provider @Produces(MediaType.APPLICATION_JSON) public class MyExceptionMapper extends…
athosga
  • 1
  • 1
0
votes
0 answers

Issue with ExceptionMapper in Jersey

I have two classes that implements ExceptionMapper interface. IllegalArgumentExceptionMapper to handle IllegalArgumentException: @Slf4j @Provider public class IllegalArgumentExceptionMapper implements ExceptionMapper { …
Yang Liu
  • 541
  • 9
  • 26
0
votes
1 answer

How to write tests for Quarkus - ResponseExceptionMapper and ExceptionMapper

I am using two exception mapper, responseexceptionmapper and exceptionmapper. Now I need to have code coverage from these mappers. Any examples ?
Sandra
  • 419
  • 7
  • 17