Class DirectTemplateExceptionMapper
- java.lang.Object
-
- ru.vyarus.guicey.gsp.app.rest.support.DirectTemplateExceptionMapper
-
- All Implemented Interfaces:
jakarta.ws.rs.ext.ExceptionMapper<jakarta.ws.rs.NotFoundException>,org.glassfish.jersey.spi.ExtendedExceptionMapper<jakarta.ws.rs.NotFoundException>
@Provider public class DirectTemplateExceptionMapper extends java.lang.Object implements org.glassfish.jersey.spi.ExtendedExceptionMapper<jakarta.ws.rs.NotFoundException>NotFoundExceptionthrown by jersey when matching rest path not found. Exception mapper detects it and if it is template call tries to render template directly instead.Handler is applied to all rest, but as its an extended mapper, it will not influence normal rest calls.
NOTE: application may declare different exception mapper for
NotFoundExceptionand so it may override this mapper. It is highly unlikely, but still could happen.Another drawback is template rendering errors will be unreachable for default dropwizard exception mapper (
IllegalStateExceptionMapperwhich logs all rest exceptions. But this is compensated by direct exception error logging.- Since:
- 06.12.2019
-
-
Constructor Summary
Constructors Constructor Description DirectTemplateExceptionMapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static booleancanHandle(org.glassfish.jersey.server.monitoring.RequestEvent event)Exception event first will be catched by listener and it must not handle it initially.booleanisMappable(jakarta.ws.rs.NotFoundException exception)jakarta.ws.rs.core.ResponsetoResponse(jakarta.ws.rs.NotFoundException exception)
-
-
-
Method Detail
-
isMappable
public boolean isMappable(jakarta.ws.rs.NotFoundException exception)
- Specified by:
isMappablein interfaceorg.glassfish.jersey.spi.ExtendedExceptionMapper<jakarta.ws.rs.NotFoundException>
-
toResponse
public jakarta.ws.rs.core.Response toResponse(jakarta.ws.rs.NotFoundException exception)
- Specified by:
toResponsein interfacejakarta.ws.rs.ext.ExceptionMapper<jakarta.ws.rs.NotFoundException>
-
canHandle
protected static boolean canHandle(org.glassfish.jersey.server.monitoring.RequestEvent event)
Exception event first will be catched by listener and it must not handle it initially. Then this exception mapper (which should be chosen as the closest match) will render direct template. If template rendering fails then exception will be redirected directly to error mapper. If it was already error rendering then 404 or 500 will be returned directly.As a side effect, template rendering errors will be impossible to intercept with custom exception mappers.
- Parameters:
event- exception event- Returns:
- true if exception mapper will handle exception (render direct template), false otherwise
-
-