pl.allegro.tech.hermes.management.api.mappers.WebApplicationExceptionMapper Maven / Gradle / Ivy
package pl.allegro.tech.hermes.management.api.mappers;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;
import jakarta.ws.rs.ext.Provider;
import pl.allegro.tech.hermes.api.ErrorCode;
import pl.allegro.tech.hermes.api.ErrorDescription;
@Provider
public class WebApplicationExceptionMapper implements ExceptionMapper {
@Override
public Response toResponse(WebApplicationException exception) {
return Response.status(exception.getResponse().getStatus())
.type(MediaType.APPLICATION_JSON_TYPE)
.entity(new ErrorDescription(exception.getMessage(), ErrorCode.OTHER))
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy