Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Import Process
Drupal Sync Service
Commits
db9ff62f
Commit
db9ff62f
authored
Nov 23, 2020
by
Jonas Waeber
Browse files
Improve error handling for invalid input types.
parent
2924c676
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/kotlin/model/InputTypeAdapter.kt
View file @
db9ff62f
...
...
@@ -19,11 +19,17 @@ package org.memobase.model
import
com.beust.klaxon.TypeAdapter
import
kotlin.reflect.KClass
import
org.apache.logging.log4j.LogManager
class
InputTypeAdapter
:
TypeAdapter
<
Input
>
{
private
val
log
=
LogManager
.
getLogger
(
"InputTypeAdapter"
)
override
fun
classFor
(
type
:
Any
):
KClass
<
out
Input
>
=
when
(
type
as
String
)
{
"node--institution"
->
Institution
::
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment