Commit db9ff62f authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Improve error handling for invalid input types.

parent 2924c676
...@@ -19,11 +19,17 @@ package org.memobase.model ...@@ -19,11 +19,17 @@ package org.memobase.model
import com.beust.klaxon.TypeAdapter import com.beust.klaxon.TypeAdapter
import kotlin.reflect.KClass import kotlin.reflect.KClass
import org.apache.logging.log4j.LogManager
class InputTypeAdapter : TypeAdapter<Input> { class InputTypeAdapter : TypeAdapter<Input> {
private val log = LogManager.getLogger("InputTypeAdapter")
override fun classFor(type: Any): KClass<out Input> = when(type as String) { override fun classFor(type: Any): KClass<out Input> = when(type as String) {
"node--institution" -> Institution::class "node--institution" -> Institution::class
"node--record_set" -> RecordSet::class "node--record_set" -> RecordSet::class
else -> throw IllegalArgumentException("Unknown type: $type") else -> {
log.error("Unknown input type: $type. Could not parse this input.")
Input::class
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment