15
15
import com .fasterxml .jackson .databind .deser .impl .ReadableObjectId ;
16
16
import com .fasterxml .jackson .databind .deser .impl .TypeWrappedDeserializer ;
17
17
import com .fasterxml .jackson .databind .exc .InvalidFormatException ;
18
+ import com .fasterxml .jackson .databind .exc .InvalidTypeIdException ;
18
19
import com .fasterxml .jackson .databind .exc .UnrecognizedPropertyException ;
19
20
import com .fasterxml .jackson .databind .introspect .Annotated ;
20
21
import com .fasterxml .jackson .databind .jsontype .TypeDeserializer ;
@@ -893,12 +894,12 @@ public JavaType handleUnknownTypeId(JavaType baseType, String id,
893
894
if (type .isTypeOrSubTypeOf (baseType .getRawClass ())) {
894
895
return type ;
895
896
}
896
- throw unknownTypeException (baseType , id ,
897
+ throw unknownTypeIdException (baseType , id ,
897
898
"problem handler tried to resolve into non-subtype: " +type );
898
899
}
899
900
h = h .next ();
900
901
}
901
- throw unknownTypeException (baseType , id , extraDesc );
902
+ throw unknownTypeIdException (baseType , id , extraDesc );
902
903
}
903
904
904
905
/*
@@ -1072,7 +1073,7 @@ public JsonMappingException mappingException(String msgTemplate, Object... args)
1072
1073
/*
1073
1074
/**********************************************************
1074
1075
/* Methods for constructing semantic exceptions; usually not
1075
- /* to be called direclty , call `handleXxx()` instead
1076
+ /* to be called directly , call `handleXxx()` instead
1076
1077
/**********************************************************
1077
1078
*/
1078
1079
@@ -1090,17 +1091,20 @@ public JsonMappingException weirdKeyException(Class<?> keyClass, String keyValue
1090
1091
}
1091
1092
1092
1093
/**
1093
- * Helper method for constructing exception to indicate that end-of-input was
1094
- * reached while still expecting more tokens to deserialize value of specified type.
1095
- *
1096
- * @deprecated Since 2.8; currently no way to catch EOF at databind level
1094
+ * Helper method for constructing exception to indicate that given JSON
1095
+ * Object field name was not in format to be able to deserialize specified
1096
+ * key type.
1097
1097
*/
1098
- @ Deprecated
1099
- public JsonMappingException endOfInputException (Class <?> instClass ) {
1100
- return JsonMappingException .from (_parser , "Unexpected end-of-input when trying to deserialize a "
1101
- +instClass .getName ());
1098
+ public JsonMappingException unknownTypeIdException (JavaType baseType , String typeId ,
1099
+ String extraDesc ) {
1100
+ String msg = String .format ("Could not resolve type id '%s' into a subtype of %s" ,
1101
+ typeId , baseType );
1102
+ if (extraDesc != null ) {
1103
+ msg = msg + ": " +extraDesc ;
1104
+ }
1105
+ return InvalidTypeIdException .from (_parser , msg , baseType , typeId );
1102
1106
}
1103
-
1107
+
1104
1108
/*
1105
1109
/**********************************************************
1106
1110
/* Methods for constructing semantic exceptions; mostly
@@ -1200,6 +1204,18 @@ public JsonMappingException unknownTypeException(JavaType type, String id,
1200
1204
return JsonMappingException .from (_parser , msg );
1201
1205
}
1202
1206
1207
+ /**
1208
+ * Helper method for constructing exception to indicate that end-of-input was
1209
+ * reached while still expecting more tokens to deserialize value of specified type.
1210
+ *
1211
+ * @deprecated Since 2.8; currently no way to catch EOF at databind level
1212
+ */
1213
+ @ Deprecated
1214
+ public JsonMappingException endOfInputException (Class <?> instClass ) {
1215
+ return JsonMappingException .from (_parser , "Unexpected end-of-input when trying to deserialize a "
1216
+ +instClass .getName ());
1217
+ }
1218
+
1203
1219
/*
1204
1220
/**********************************************************
1205
1221
/* Overridable internal methods
0 commit comments