more minor tweaks to exception routing
diff --git a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java
index 53d8ea9..0f0e7a5 100644
--- a/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java
+++ b/src/main/java/com/fasterxml/jackson/databind/SerializerProvider.java
@@ -1168,11 +1168,10 @@
return;
}
}
- throw JsonMappingException.from(this,
- "Incompatible types: declared root type ("+rootType+") vs "
- +value.getClass().getName());
+ reportMappingProblem("Incompatible types: declared root type (%s) vs %s",
+ rootType, value.getClass().getName());
}
-
+
/**
* Method that will try to find a serializer, either from cache
* or by constructing one; but will not return an "unknown" serializer
@@ -1225,7 +1224,8 @@
/* We better only expose checked exceptions, since those
* are what caller is expected to handle
*/
- throw JsonMappingException.from(this, iae.getMessage(), iae);
+ reportMappingProblem(iae, iae.getMessage());
+ return null; // never gets here
}
if (ser != null) {
@@ -1245,7 +1245,8 @@
/* We better only expose checked exceptions, since those
* are what caller is expected to handle
*/
- throw JsonMappingException.from(this, iae.getMessage(), iae);
+ reportMappingProblem(iae, iae.getMessage());
+ return null; // never gets here
}
if (ser != null) {
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/SetterlessProperty.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/SetterlessProperty.java
index 4daaaed..fa8f9ed 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/SetterlessProperty.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/SetterlessProperty.java
@@ -94,9 +94,10 @@
// For [#501] fix we need to implement this but:
if (_valueTypeDeserializer != null) {
- throw JsonMappingException.from(p,
- "Problem deserializing 'setterless' property (\""+getName()+"\"): no way to handle typed deser with setterless yet");
-// return _valueDeserializer.deserializeWithType(jp, ctxt, _valueTypeDeserializer);
+ ctxt.reportMappingException(
+ "Problem deserializing 'setterless' property (\"%s\"): no way to handle typed deser with setterless yet",
+ getName());
+// return _valueDeserializer.deserializeWithType(p, ctxt, _valueTypeDeserializer);
}
// Ok: then, need to fetch Collection/Map to modify:
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java
index 2236fce..0dd2a45 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/CollectionDeserializer.java
@@ -302,12 +302,12 @@
}
@Override
- public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt,
+ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt,
TypeDeserializer typeDeserializer)
throws IOException
{
// In future could check current token... for now this should be enough:
- return typeDeserializer.deserializeTypedFromArray(jp, ctxt);
+ return typeDeserializer.deserializeTypedFromArray(p, ctxt);
}
/**
diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer.java
index 4617157..e480b78 100644
--- a/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/JsonNodeDeserializer.java
@@ -165,6 +165,7 @@
/**********************************************************
*/
+ @Deprecated // since 2.8
protected void _reportProblem(JsonParser p, String msg) throws JsonMappingException {
throw JsonMappingException.from(p, msg);
}
@@ -188,9 +189,10 @@
JsonNode oldValue, JsonNode newValue)
throws JsonProcessingException
{
- // [Issue#237]: Report an error if asked to do so:
+ // [databind#237]: Report an error if asked to do so:
if (ctxt.isEnabled(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY)) {
- _reportProblem(p, "Duplicate field '"+fieldName+"' for ObjectNode: not allowed when FAIL_ON_READING_DUP_TREE_KEY enabled");
+ ctxt.reportMappingException("Duplicate field '%s' for ObjectNode: not allowed when FAIL_ON_READING_DUP_TREE_KEY enabled",
+ fieldName);
}
}
diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java
index 34190b3..793a49c 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java
@@ -85,16 +85,14 @@
try {
objectNode.set("properties", _getObjectMapper().readTree(objectProperties));
} catch (IOException e) {
- throw JsonMappingException.from(provider,
- "Failed to parse @JsonSerializableSchema.schemaObjectPropertiesDefinition value");
+ provider.reportMappingProblem("Failed to parse @JsonSerializableSchema.schemaObjectPropertiesDefinition value");
}
}
if (itemDefinition != null) {
try {
objectNode.set("items", _getObjectMapper().readTree(itemDefinition));
} catch (IOException e) {
- throw JsonMappingException.from(provider,
- "Failed to parse @JsonSerializableSchema.schemaItemDefinition value");
+ provider.reportMappingProblem("Failed to parse @JsonSerializableSchema.schemaItemDefinition value");
}
}
// always optional, no need to specify: