Commit 419f1705 authored by Gwenael Cattez's avatar Gwenael Cattez

Add specific exception to send HTTP status as error

parent b25f8ef7
/**
* OW2 FraSCAti Demo
* Copyright (C) 2008-2010 INRIA, University of Lille 1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact: frascati@ow2.org
*
* Author: Gwenael CATTEZ
*
* Contributor(s):
*/
package org.ow2.frascati.remote.introspection.exception;
import java.util.logging.Logger;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/**
*
*/
public class MyWebApplicationException extends WebApplicationException
{
private static final long serialVersionUID = -6209569322081835480L;
private final static int DEFAULT_RESPONSE=400;
protected final static Logger LOG = Logger.getLogger(MyWebApplicationException.class.getCanonicalName());
public MyWebApplicationException(int status,String message)
{
super(Response.status(status).entity(message).type(MediaType.TEXT_PLAIN).build());
LOG.severe("Error "+status+" "+MyWebApplicationException.class.getSimpleName()+" : "+message);
}
public MyWebApplicationException(Exception e,int status,String message)
{
super(e,Response.status(status).entity(message).type(MediaType.TEXT_PLAIN).build());
LOG.severe("Error "+status+" "+e.getClass().getSimpleName()+" : "+message);
e.printStackTrace();
}
public MyWebApplicationException(String message)
{
this(DEFAULT_RESPONSE,message);
}
public MyWebApplicationException(Exception e,String message)
{
this(e,DEFAULT_RESPONSE,message);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment