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

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

import com.sun.jersey.api.Responses;

public class NoRepresentationException extends WebApplicationException {
	private static final long serialVersionUID = 1873195154804536511L;
	 
	/**
	 * Constructs a NoRepresentationException, without any 
	 * specific associated description of the exception.
	 */
    public NoRepresentationException() {
    	super(Responses.notAcceptable().build());
    }
 
    /**
     * Constructs a NoRepresentationException, 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 NoRepresentationException(String message) {
		super(Response.status(Responses.NOT_ACCEPTABLE).
				entity(message).type("text/plain").build());
    }
    
    /**
     * Constructs a NoRepresentationException, 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 NoRepresentationException(Throwable cause) {
    	super(cause, Response.status(Responses.NOT_ACCEPTABLE).
				entity(cause.getMessage()).type("text/plain").build());
    }
 
    /**
     * Constructs a NoRepresentationException, 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 NoRepresentationException(String message, Throwable cause) {
		super(cause, Response.status(Responses.NOT_ACCEPTABLE).
				entity(message).type("text/plain").build());
    }
}
