From 6f8eb974012fcacb26988f10cef6c8eec348582e Mon Sep 17 00:00:00 2001 From: Alessandro Ciccimarra Date: Sat, 22 Feb 2020 10:39:24 +0000 Subject: [PATCH] Log task name on failure When multiple tasks are scheduled and something goes wrong with them, it could be useful to know which ones failed. --- .../main/java/com/github/kagkarlsson/scheduler/Scheduler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java index 445c97b6..089d45e8 100644 --- a/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java +++ b/db-scheduler/src/main/java/com/github/kagkarlsson/scheduler/Scheduler.java @@ -323,12 +323,12 @@ private void executePickedExecution(Execution execution) { statsRegistry.register(StatsRegistry.ExecutionStatsEvent.COMPLETED); } catch (RuntimeException unhandledException) { - LOG.error("Unhandled exception during execution. Treating as failure.", unhandledException); + LOG.error("Unhandled exception during execution of task with name '{}'. Treating as failure.", task.get().getName(), unhandledException); failure(task.get().getFailureHandler(), execution, unhandledException, executionStarted); statsRegistry.register(StatsRegistry.ExecutionStatsEvent.FAILED); } catch (Throwable unhandledError) { - LOG.error("Error during execution. Treating as failure.", unhandledError); + LOG.error("Error during execution of task with name '{}'. Treating as failure.", task.get().getName(), unhandledError); failure(task.get().getFailureHandler(), execution, unhandledError, executionStarted); statsRegistry.register(StatsRegistry.ExecutionStatsEvent.FAILED); }