001/* 002 * Copyright 2002-2017 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.util; 018 019/** 020 * Exception thrown from {@link MimeTypeUtils#parseMimeType(String)} in case of 021 * encountering an invalid content type specification String. 022 * 023 * @author Juergen Hoeller 024 * @author Rossen Stoyanchev 025 * @since 4.0 026 */ 027@SuppressWarnings("serial") 028public class InvalidMimeTypeException extends IllegalArgumentException { 029 030 private final String mimeType; 031 032 033 /** 034 * Create a new InvalidContentTypeException for the given content type. 035 * @param mimeType the offending media type 036 * @param message a detail message indicating the invalid part 037 */ 038 public InvalidMimeTypeException(String mimeType, String message) { 039 super("Invalid mime type \"" + mimeType + "\": " + message); 040 this.mimeType = mimeType; 041 } 042 043 044 /** 045 * Return the offending content type. 046 */ 047 public String getMimeType() { 048 return this.mimeType; 049 } 050 051}