Commit 4e2f5c34 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Add error message to local transform.

parent c2bf592b
Pipeline #16102 passed with stage
in 1 minute and 58 seconds
......@@ -15,29 +15,35 @@ class LocalTransformsLoader(data: ByteArray) {
private val log = LogManager.getLogger("LocalTransformsLoader")
private val objectMapper = ObjectMapper(YAMLFactory()).registerKotlinModule()
private val transforms: LocalTransform
val errorMessage: String
private val transforms: LocalTransform?
init {
var message = ""
transforms = try {
objectMapper.readValue(ByteArrayInputStream(data), LocalTransform::class.java)
} catch (ex: MismatchedInputException) {
log.error("The local transform file could not be parsed: ${ex.localizedMessage}.")
throw InvalidMappingException("The local transform file could not be parsed: ${ex.localizedMessage}.")
message = "The local transform file could not be parsed: ${ex.localizedMessage}."
log.error(message)
null
} catch (ex: InvalidMappingException) {
log.error(ex.localizedMessage)
throw InvalidMappingException(ex.localizedMessage)
message = "The local transform file could not be parsed: ${ex.localizedMessage}."
log.error(message)
null
} catch (ex: Exception) {
log.error("Unknown exception while parsing local transform: ${ex.localizedMessage}.")
throw InvalidMappingException("Unknown exception while parsing local transform: ${ex.localizedMessage}.")
message = "Unknown exception while parsing local transform: ${ex.localizedMessage}."
log.error(message)
null
}
errorMessage = message
}
fun get(): List<ITransformer> {
val localTransforms = mutableListOf<ITransformer>()
transforms.splitEntity?.forEach {
transforms?.splitEntity?.forEach {
localTransforms.add(it.generate())
}
transforms.normalizePerson?.generate().let {
transforms?.normalizePerson?.generate().let {
if (it != null) {
localTransforms.addAll(it)
}
......
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