From 42211a6d45558bf77063bef0b42a7fe9e2debb46 Mon Sep 17 00:00:00 2001 From: Walter Oggioni <6357328+woggioni@users.noreply.github.com> Date: Mon, 6 Apr 2020 09:48:35 +0100 Subject: [PATCH] fixed bug in error reporting (#6127) the current code doesn't forward the exception to the logging system, this means that any cause inside the exception is lost as with all of the stacktraces (both the one of the thrown exception and the one belonging to its cause). The correct way to log an exception is to pass both the message and the exception to the logging system. --- .../lifecycle/NodeLifecycleEventsDistributor.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/lifecycle/NodeLifecycleEventsDistributor.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/lifecycle/NodeLifecycleEventsDistributor.kt index 4672ff85ac..7c2454c857 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/lifecycle/NodeLifecycleEventsDistributor.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/lifecycle/NodeLifecycleEventsDistributor.kt @@ -98,11 +98,12 @@ class NodeLifecycleEventsDistributor : Closeable { orderedSnapshot.forEach { log.debug("Distributing event $event to: $it") val updateResult = it.update(event) - if (updateResult.isSuccess) { - log.debug("Event $event distribution outcome: $updateResult") - } else { - log.error("Failed to distribute event $event, failure outcome: $updateResult") - handlePossibleFatalTermination(event, updateResult as Try.Failure) + when(updateResult) { + is Try.Success -> log.debug("Event $event distribution outcome: $updateResult") + is Try.Failure -> { + log.error("Failed to distribute event $event, failure outcome: $updateResult", updateResult.exception) + handlePossibleFatalTermination(event, updateResult) + } } } result.set(null)