001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.http.commons.exceptionhandlers;
007
008import static org.slf4j.LoggerFactory.getLogger;
009
010import javax.ws.rs.core.Response;
011import javax.ws.rs.ext.ExceptionMapper;
012import javax.ws.rs.ext.Provider;
013
014import org.fcrepo.kernel.api.exception.PathNotFoundException;
015import org.slf4j.Logger;
016
017
018/**
019 * Catch PathNotFoundException
020 *
021 * @author robyj
022 */
023@Provider
024public class PathNotFoundExceptionMapper implements
025        ExceptionMapper<PathNotFoundException>, ExceptionDebugLogging {
026
027    private static final Logger LOGGER =
028        getLogger(PathNotFoundExceptionMapper.class);
029
030    @Override
031    public Response toResponse(final PathNotFoundException e) {
032        debugException(this, e, LOGGER);
033        return Response.status(Response.Status.NOT_FOUND).
034                entity("Error: " + e.getMessage()).build();
035    }
036}
037