Skip to content

Commit

Permalink
Remove MissingKotlinParameterException and replace with MismatchedInp…
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Mar 18, 2023
1 parent 0a14f44 commit 8143470
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
16 changes: 0 additions & 16 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
@@ -1,10 +1,10 @@
package com.fasterxml.jackson.module.kotlin.deser

import com.fasterxml.jackson.databind.JavaType
import com.fasterxml.jackson.databind.exc.MismatchedInputException
import com.fasterxml.jackson.databind.type.TypeFactory
import com.fasterxml.jackson.databind.util.Converter
import com.fasterxml.jackson.databind.util.StdConverter
import com.fasterxml.jackson.module.kotlin.MissingKotlinParameterException
import com.fasterxml.jackson.module.kotlin.deser.value_instantiator.creator.ValueParameter

internal class ValueClassUnboxConverter<T : Any>(private val valueClass: Class<T>) : StdConverter<T, Any?>() {
Expand All @@ -26,9 +26,9 @@ internal sealed class CollectionValueStrictNullChecksConverter<T : Any> : Conver
override fun convert(value: T): T {
getValues(value).forEach {
if (it == null) {
throw MissingKotlinParameterException(
valueParameter,
throw MismatchedInputException.from(
null,
null as JavaType?,
"A null value was entered for the parameter ${valueParameter.name}."
)
}
Expand Down Expand Up @@ -62,9 +62,9 @@ internal class MapValueStrictNullChecksConverter(
override fun convert(value: Map<*, *>): Map<*, *> = value.apply {
entries.forEach { (k, v) ->
if (v == null) {
throw MissingKotlinParameterException(
valueParameter,
throw MismatchedInputException.from(
null,
null as JavaType?,
"A null value was entered for key $k of the parameter ${valueParameter.name}."
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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.module.kotlin.MissingKotlinParameterException
import com.fasterxml.jackson.databind.exc.MismatchedInputException
import com.fasterxml.jackson.module.kotlin.ReflectionCache
import com.fasterxml.jackson.module.kotlin.deser.value_instantiator.creator.ValueCreator
import java.lang.reflect.Executable
Expand Down Expand Up @@ -67,10 +67,10 @@ internal class KotlinValueInstantiator(
} else {
val isMissingAndRequired = isMissing && jsonProp.isRequired
if (isMissingAndRequired || (!paramDef.isGenericType && !paramDef.isNullable)) {
throw MissingKotlinParameterException(
parameter = paramDef,
processor = ctxt.parser,
msg = "Instantiation of $valueTypeDesc value failed for JSON property ${jsonProp.name} " +
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 Down

0 comments on commit 8143470

Please sign in to comment.