001/*
002 * Copyright 2002-2015 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.multipart;
018
019/**
020 * MultipartException subclass thrown when an upload exceeds the
021 * maximum upload size allowed.
022 *
023 * @author Juergen Hoeller
024 * @since 1.0.1
025 */
026@SuppressWarnings("serial")
027public class MaxUploadSizeExceededException extends MultipartException {
028
029        private final long maxUploadSize;
030
031
032        /**
033         * Constructor for MaxUploadSizeExceededException.
034         * @param maxUploadSize the maximum upload size allowed
035         */
036        public MaxUploadSizeExceededException(long maxUploadSize) {
037                this(maxUploadSize, null);
038        }
039
040        /**
041         * Constructor for MaxUploadSizeExceededException.
042         * @param maxUploadSize the maximum upload size allowed
043         * @param ex root cause from multipart parsing API in use
044         */
045        public MaxUploadSizeExceededException(long maxUploadSize, Throwable ex) {
046                super("Maximum upload size of " + maxUploadSize + " bytes exceeded", ex);
047                this.maxUploadSize = maxUploadSize;
048        }
049
050
051        /**
052         * Return the maximum upload size allowed.
053         */
054        public long getMaxUploadSize() {
055                return this.maxUploadSize;
056        }
057
058}