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

Add general exception handler

Fix report.
parent 65ae0baa
Pipeline #30526 passed with stages
in 3 minutes and 27 seconds
......@@ -85,7 +85,12 @@ class KafkaTopology(
handledStream[0]
.mapValues { readOnlyKey, value ->
Report(readOnlyKey, ReportStatus.fatal, "CONFIGURATION ERROR: ${value.third}", reportingStepName).toJson()
Report(
readOnlyKey,
ReportStatus.fatal,
"CONFIGURATION ERROR: ${value.third}",
reportingStepName
).toJson()
}
.to(reportTopic)
......@@ -258,27 +263,59 @@ class KafkaTopology(
Triple(parsedSource, mapperConfiguration.get(), null)
} else {
log.error("Parsed source is empty: ${value.first}.")
Triple(null, null, Report(key, ReportStatus.fatal, "Could not parse source document.", reportingStepName))
Triple(
null,
null,
Report(key, ReportStatus.fatal, "Could not parse source document.", reportingStepName)
)
}
} catch (ex: InvalidMappingException) {
log.error(ex.localizedMessage)
Triple(null, null, Report(key, ReportStatus.fatal, "InvalidMappingException: ${ex.localizedMessage}", reportingStepName))
Triple(
null,
null,
Report(key, ReportStatus.fatal, "InvalidMappingException: ${ex.localizedMessage}", reportingStepName)
)
} catch (ex: KlaxonException) {
log.error(ex.localizedMessage)
Triple(null, null, Report(key, ReportStatus.fatal, "KLAXON EXCEPTION: ${ex.localizedMessage}", reportingStepName))
Triple(
null,
null,
Report(key, ReportStatus.fatal, "KLAXON EXCEPTION: ${ex.localizedMessage}", reportingStepName)
)
} catch (ex: NullPointerException) {
log.error(ex.localizedMessage)
Triple(
null,
null,
Report(key, ReportStatus.fatal, "There's no data to be processed: ${ex.localizedMessage}", reportingStepName)
Report(
key,
ReportStatus.fatal,
"There's no data to be processed: ${ex.localizedMessage}",
reportingStepName
)
)
} catch (ex: IllegalArgumentException) {
log.error(ex.localizedMessage)
Triple(null, null, Report(key, ReportStatus.fatal, ex.localizedMessage, Service.step))
Triple(
null,
null,
Report(key, ReportStatus.fatal, "IllegalArgumentException: ${ex.localizedMessage}", reportingStepName)
)
} catch (ex: ScannerException) {
log.error(ex.localizedMessage)
Triple(null, null, Report(key, ReportStatus.fatal, ex.localizedMessage, Service.step))
Triple(
null,
null,
Report(key, ReportStatus.fatal, "ScannerException: ${ex.localizedMessage}", reportingStepName)
)
} catch (ex: Exception) {
log.error(ex.localizedMessage)
Triple(
null,
null,
Report(key, ReportStatus.fatal, "${ex::class.java.name}: ${ex.localizedMessage}", reportingStepName)
)
}
}
}
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