/** * Helper method for constructing exception to indicate that given JSON Object field name was not * in format to be able to deserialize specified key type. */ public JsonMappingException weirdKeyException(Class<?> keyClass, String keyValue, String msg) { return InvalidFormatException.from( _parser, "Can not construct Map key of type " + keyClass.getName() + " from String \"" + _desc(keyValue) + "\": " + msg, keyValue, keyClass); }
/** * Helper method for constructing exception to indicate that input JSON Number was not suitable * for deserializing into given target type. */ public JsonMappingException weirdNumberException(Number value, Class<?> instClass, String msg) { return InvalidFormatException.from( _parser, "Can not construct instance of " + instClass.getName() + " from number value (" + _valueDesc() + "): " + msg, null, instClass); }
/** * Method that will construct an exception suitable for throwing when some String values are * acceptable, but the one encountered is not. * * @param value String value from input being deserialized * @param instClass Type that String should be deserialized into * @param msg Message that describes specific problem * @since 2.1 */ public JsonMappingException weirdStringException(String value, Class<?> instClass, String msg) { return InvalidFormatException.from( _parser, "Can not construct instance of " + instClass.getName() + " from String value '" + _valueDesc() + "': " + msg, value, instClass); }
protected String _calcName(Class<?> cls) { if (cls.isArray()) { return _calcName(cls.getComponentType()) + "[]"; } return cls.getName(); }
public JsonMappingException endOfInputException(Class<?> instClass) { return JsonMappingException.from( _parser, "Unexpected end-of-input when trying to deserialize a " + instClass.getName()); }
public JsonMappingException instantiationException(Class<?> instClass, String msg) { return JsonMappingException.from( _parser, "Can not construct instance of " + instClass.getName() + ", problem: " + msg); }
/** * Helper method for constructing instantiation exception for specified type, to indicate problem * with physically constructing instance of specified class (missing constructor, exception from * constructor) */ public JsonMappingException instantiationException(Class<?> instClass, Throwable t) { return JsonMappingException.from( _parser, "Can not construct instance of " + instClass.getName() + ", problem: " + t.getMessage(), t); }