All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.minijax.json.MinijaxJsonExceptionMapper Maven / Gradle / Ivy

There is a newer version: 0.5.10
Show newest version
package org.minijax.json;

import static javax.ws.rs.core.MediaType.*;

import javax.inject.Singleton;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;

import org.minijax.util.ExceptionUtils;

@Singleton
@Produces(APPLICATION_JSON)
public class MinijaxJsonExceptionMapper implements ExceptionMapper {

    @Override
    public Response toResponse(final Exception exception) {
        final WebApplicationException webAppEx = ExceptionUtils.toWebAppException(exception);
        return Response
                .status(webAppEx.getResponse().getStatus())
                .type(APPLICATION_JSON_TYPE)
                .entity(new MinijaxJsonExceptionWrapper(webAppEx))
                .build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy