package be.ac.ulb.code.wit.resources.serializers;

import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;

import com.sun.jersey.api.Responses;

public class MalformedRequestException extends WebApplicationException {
	private static final long serialVersionUID = 1873195154804536511L;
	 
	/**
	 * Constructs a MalformedRequestException, without any 
	 * specific associated description of the exception.
	 */
    public MalformedRequestException() {
    	super(Responses.notFound().build());
    }
 
    /**
     * Constructs a MalformedRequestException, with the specified message describing
     * the exception.
     * @param message The String that describes why the exception was thrown
     * 				  and that is used in the response to the client.
     */
    public MalformedRequestException(String message) {
		super(Response.status(Responses.NOT_FOUND).
				entity(message).type("text/plain").build());
    }
    
    /**
     * Constructs a MalformedRequestException, with the specified underlying cause.
     * @param cause The underlying cause of the exception. The message of this
     * 				cause is used in the response to the client. 
     */
    public MalformedRequestException(Throwable cause) {
    	super(cause, Response.status(Responses.NOT_FOUND).
				entity(cause.getMessage()).type("text/plain").build());
    }
 
    /**
     * Constructs a MalformedRequestException, with the specified cause and  message describing
     * the exception.
     * @param cause The underlying cause of the exception. 
     * @param message The String that describes why the exception was thrown
     * 		  and that is used in the response to the client. 
     */
    public MalformedRequestException(String message, Throwable cause) {
		super(cause, Response.status(Responses.NOT_FOUND).
				entity(message).type("text/plain").build());
    }
}
