Skip to content

Commit ac32eb8

Browse files
committed
Remove MissingKotlinParameterException and replace with MismatchedInputException
fixes #617
1 parent 25a54ff commit ac32eb8

File tree

2 files changed

+11
-40
lines changed

2 files changed

+11
-40
lines changed

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

Lines changed: 0 additions & 32 deletions
This file was deleted.

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.deser.ValueInstantiators
99
import com.fasterxml.jackson.databind.deser.impl.NullsAsEmptyProvider
1010
import com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer
1111
import com.fasterxml.jackson.databind.deser.std.StdValueInstantiator
12+
import com.fasterxml.jackson.databind.exc.MismatchedInputException
1213
import java.lang.reflect.TypeVariable
1314
import kotlin.reflect.KParameter
1415
import kotlin.reflect.KType
@@ -81,10 +82,12 @@ internal class KotlinValueInstantiator(
8182
val isMissingAndRequired = paramVal == null && isMissing && jsonProp.isRequired
8283
if (isMissingAndRequired ||
8384
(!isGenericTypeVar && paramVal == null && !paramDef.type.isMarkedNullable)) {
84-
throw MissingKotlinParameterException(
85-
parameter = paramDef,
86-
processor = ctxt.parser,
87-
msg = "Instantiation of ${this.valueTypeDesc} value failed for JSON property ${jsonProp.name} due to missing (therefore NULL) value for creator parameter ${paramDef.name} which is a non-nullable type"
85+
throw MismatchedInputException.from(
86+
ctxt.parser,
87+
jsonProp.type,
88+
"Instantiation of $valueTypeDesc value failed for JSON property ${jsonProp.name} " +
89+
"due to missing (therefore NULL) value for creator parameter ${paramDef.name} " +
90+
"which is a non-nullable type"
8891
).wrapWithPath(this.valueClass, jsonProp.name)
8992
}
9093

@@ -107,10 +110,10 @@ internal class KotlinValueInstantiator(
107110
}
108111

109112
if (paramType != null && itemType != null) {
110-
throw MissingKotlinParameterException(
111-
parameter = paramDef,
112-
processor = ctxt.parser,
113-
msg = "Instantiation of $itemType $paramType failed for JSON property ${jsonProp.name} due to null value in a $paramType that does not allow null values"
113+
throw MismatchedInputException.from(
114+
ctxt.parser,
115+
jsonProp.type,
116+
"Instantiation of $itemType $paramType failed for JSON property ${jsonProp.name} due to null value in a $paramType that does not allow null values"
114117
).wrapWithPath(this.valueClass, jsonProp.name)
115118
}
116119
}

0 commit comments

Comments
 (0)