I use Jersey and Guice is my IOC container. I would like to know if ExceptionMapper can be associated with a specific URI. The reason for this is because I want to map the same exception differently based on which URI was visited. For example, suppose I have the following two exceptions for my custom exception:
public class MyExceptionMapperForFirstURI implements ExceptionMapper<MyException> {..return response based on first URI..} public class MyExceptionMapperForSecondURI implements ExceptionMapper<MyException> {..return response based on second URI..}
As far as I understand, you bind ExceptionMapper in your ServletModule as follows:
public class MyModule extends ServletModule { @Override public void configureServlets() { super.configureServlets(); bind(MyCustomExceptionMapper.class); } }
How would I contact the MyExceptionMapperForFirstURI and MyExceptionMapperForSecondURI so that they are associated with the correct URIs. Is it possible, and if it is possible: is it right to do it?
source share