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

org.jboss.pnc.environmentdriver.exceptions.mappers.UnableToRequestResourcesExceptionMapper Maven / Gradle / Ivy

Go to download

Environment driver provides REST endpoints to create and destroy Openshift objects

There is a newer version: 3.0.0
Show newest version
package org.jboss.pnc.environmentdriver.exceptions.mappers;

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

import org.jboss.pnc.api.dto.ErrorResponse;
import org.jboss.pnc.environmentdriver.exceptions.UnableToRequestResourcesException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Provider
public class UnableToRequestResourcesExceptionMapper implements ExceptionMapper {

    private static final Logger logger = LoggerFactory.getLogger(UnableToRequestResourcesExceptionMapper.class);

    @Override
    public Response toResponse(UnableToRequestResourcesException e) {
        logger.error("An exception occurred while requesting resources", e);

        Response.ResponseBuilder builder = Response.status(Response.Status.BAD_REQUEST.getStatusCode());
        builder.entity(new ErrorResponse(e)).type(MediaType.APPLICATION_JSON);

        return builder.build();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy