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

ca.ibodrov.mica.server.exceptions.DataAccessExceptionMapper Maven / Gradle / Ivy

There is a newer version: 0.0.25
Show newest version
package ca.ibodrov.mica.server.exceptions;

import ca.ibodrov.mica.api.model.ApiError;
import com.walmartlabs.concord.server.sdk.rest.Component;
import org.jooq.exception.DataAccessException;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

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

@Provider
public class DataAccessExceptionMapper implements Component, ExceptionMapper {

    @Override
    public Response toResponse(DataAccessException exception) {
        return Response.serverError()
                .type(APPLICATION_JSON)
                .entity(ApiError.internalError(exception.getMessage()))
                .build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy