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.core.convert; 018 019import org.springframework.lang.Nullable; 020 021/** 022 * Exception to be thrown when a suitable converter could not be found 023 * in a given conversion service. 024 * 025 * @author Keith Donald 026 * @author Juergen Hoeller 027 * @since 3.0 028 */ 029@SuppressWarnings("serial") 030public class ConverterNotFoundException extends ConversionException { 031 032 @Nullable 033 private final TypeDescriptor sourceType; 034 035 private final TypeDescriptor targetType; 036 037 038 /** 039 * Create a new conversion executor not found exception. 040 * @param sourceType the source type requested to convert from 041 * @param targetType the target type requested to convert to 042 */ 043 public ConverterNotFoundException(@Nullable TypeDescriptor sourceType, TypeDescriptor targetType) { 044 super("No converter found capable of converting from type [" + sourceType + "] to type [" + targetType + "]"); 045 this.sourceType = sourceType; 046 this.targetType = targetType; 047 } 048 049 050 /** 051 * Return the source type that was requested to convert from. 052 */ 053 @Nullable 054 public TypeDescriptor getSourceType() { 055 return this.sourceType; 056 } 057 058 /** 059 * Return the target type that was requested to convert to. 060 */ 061 public TypeDescriptor getTargetType() { 062 return this.targetType; 063 } 064 065}