Skip to content

Commit

Permalink
Remove MissingKotlinParameterException and replace with MismatchedInp…
Browse files Browse the repository at this point in the history
…utException

fixes #617
  • Loading branch information
k163377 committed Jul 8, 2023
1 parent 25a54ff commit ac32eb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 40 deletions.
32 changes: 0 additions & 32 deletions src/main/kotlin/com/fasterxml/jackson/module/kotlin/Exceptions.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.deser.ValueInstantiators
import com.fasterxml.jackson.databind.deser.impl.NullsAsEmptyProvider
import com.fasterxml.jackson.databind.deser.impl.PropertyValueBuffer
import com.fasterxml.jackson.databind.deser.std.StdValueInstantiator
import com.fasterxml.jackson.databind.exc.MismatchedInputException
import java.lang.reflect.TypeVariable
import kotlin.reflect.KParameter
import kotlin.reflect.KType
Expand Down Expand Up @@ -81,10 +82,12 @@ internal class KotlinValueInstantiator(
val isMissingAndRequired = paramVal == null && isMissing && jsonProp.isRequired
if (isMissingAndRequired ||
(!isGenericTypeVar && paramVal == null && !paramDef.type.isMarkedNullable)) {
throw MissingKotlinParameterException(
parameter = paramDef,
processor = ctxt.parser,
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"
throw MismatchedInputException.from(
ctxt.parser,
jsonProp.type,
"Instantiation of $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"
).wrapWithPath(this.valueClass, jsonProp.name)
}

Expand All @@ -107,10 +110,10 @@ internal class KotlinValueInstantiator(
}

if (paramType != null && itemType != null) {
throw MissingKotlinParameterException(
parameter = paramDef,
processor = ctxt.parser,
msg = "Instantiation of $itemType $paramType failed for JSON property ${jsonProp.name} due to null value in a $paramType that does not allow null values"
throw MismatchedInputException.from(
ctxt.parser,
jsonProp.type,
"Instantiation of $itemType $paramType failed for JSON property ${jsonProp.name} due to null value in a $paramType that does not allow null values"
).wrapWithPath(this.valueClass, jsonProp.name)
}
}
Expand Down

0 comments on commit ac32eb8

Please sign in to comment.