Skip to content

Commit f4a5449

Browse files
committed
Added nullability indication to error message
1 parent ec2f84e commit f4a5449

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/Extensions.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ inline fun <reified T> Any?.checkTypeMismatch(): T {
5959
// Since this can be caused by both input or ObjectMapper implementation errors,
6060
// a more abstract RuntimeJsonMappingException is thrown.
6161
if (this !is T) {
62+
val nullability = if (null is T) "?" else "(non-null)"
63+
6264
// Since the databind implementation of MappingIterator throws RuntimeJsonMappingException,
6365
// JsonMappingException was not used to unify the behavior.
6466
throw RuntimeJsonMappingException(
6567
"Deserialized value did not match the specified type; " +
66-
"specified ${T::class.qualifiedName} but was ${this?.let { it::class.qualifiedName }}"
68+
"specified ${T::class.qualifiedName}${nullability} but was ${this?.let { it::class.qualifiedName }}"
6769
)
6870
}
6971
return this

0 commit comments

Comments
 (0)