blob: ba975ae227b6425997727b71f6057d81b702a6cc [file] [log] [blame]
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Thomas Vachuskaa026be72015-12-07 16:00:37 -080016
17package org.onlab.rest.exceptions;
18
19import org.slf4j.Logger;
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -080020
21import javax.ws.rs.core.Response;
Ray Milkey05b169d2015-08-13 14:33:33 -070022import javax.ws.rs.ext.Provider;
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -080023
Ray Milkey8fba1c82015-11-17 09:23:24 -080024import static org.slf4j.LoggerFactory.getLogger;
25
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -080026/**
Ray Milkey2287d882015-01-30 10:15:20 -080027 * Mapper for service not found exceptions to the INTERNAL_SERVER_ERROR response code.
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -080028 */
Ray Milkey05b169d2015-08-13 14:33:33 -070029@Provider
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -080030public class ServerErrorMapper extends AbstractMapper<RuntimeException> {
Ray Milkey8fba1c82015-11-17 09:23:24 -080031 private static final Logger log = getLogger(ServerErrorMapper.class);
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -080032 @Override
33 protected Response.Status responseStatus() {
Ray Milkey8fba1c82015-11-17 09:23:24 -080034 log.warn("Unhandled REST exception", error);
Thomas Vachuskaca60f2b2014-11-06 01:34:28 -080035 return Response.Status.INTERNAL_SERVER_ERROR;
36 }
37}