Class InvalidConversionException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.juneau.commons.conversion.InvalidConversionException
All Implemented Interfaces:
Serializable

Thrown by Converter.to(Object, Class) when no conversion path exists between two types.

This is an unchecked exception. Callers that are uncertain whether a conversion is possible should call Converter.canConvert(Class, Class) first, or catch this exception and handle accordingly.

Example:

try { Integer x = BasicConverter.INSTANCE.to("hello", Integer.class); } catch (InvalidConversionException e) { // Handle unsupported conversion } // Or check first: if (BasicConverter.INSTANCE.canConvert(String.class, Integer.class)) { Integer x = BasicConverter.INSTANCE.to("42", Integer.class); }

See Also:
  • Constructor Details

    • InvalidConversionException

      public InvalidConversionException(Class<?> inType, Class<?> outType)
      Constructor.
      Parameters:
      inType - The runtime type of the input object.
      outType - The target output type.