/* ======================================================================
   Parts Copyright 2006 University of Leeds, Oxford University, University of the Highlands and Islands.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

====================================================================== */

package org.bodington.servlet;

import javax.servlet.ServletException;

/**
 * Exception for dealing with requests that are two large.
 * Currently thrown by Request when the input is too large.
 * We use an Exception as it disrupts the existing code least.
 * @author buckett
 */
public class RequestSizeException extends ServletException
{
    private long limit;

    /**
     * Create a new RequestSizeException specifying
     * the limit that was exceeded.
     * @param limit
     */
    public RequestSizeException (long limit)
    {
        super();
        this.limit = limit;
    }
    
    /**
     * Get the Exception message.
     * Displays the limit that was exceeded.
     */
    public String getMessage()
    {
        return "Request exceeded the size limit of "+ limit+ " bytes.";
    }
    
    /**
     * Get the request limit.
     * @return The number of bytes that the limit is currently set to.
     */
    public long getLimit()
    {
        return limit;
    }
}
