0

I want to understand the logic of JAX-RS with ExceptionMapper

lets assume that I have class

    @Provider
    @Singleton
    public class MyExceptionMapper implements ExceptionMapper<ApiException> {

        /**
         * check the exception type and build Response with the status body and the type of the error
         */
        @Override
        public Response toResponse(ApiException exception) {
            ........
        }
    }

How is call this class ? I saw that there is class ApplicationPrivderBinder that has method getExceptionMapper

Does it is the logic?

Who call to this method ? where is the call to the method toResponse from the

interface ExceptionMapper
user1365697
  • 5,819
  • 15
  • 60
  • 96

1 Answers1

1

The JAX-RS framework does automatically call this when an exception of the specified type (here: ApiException) propagates out of a resource method.

gsl
  • 676
  • 5
  • 16
  • 1
    By "everrest" you're refering to SerfJ (http://serfj.sourceforge.net/), right? It does implement the JAX-RS standard, so it will behave the same way, since exception mappers are defined by JAX-RS. – gsl Jan 10 '17 at 12:37