From 957b256de8783c8deb4147f43df6a3d8ccb9a7ae Mon Sep 17 00:00:00 2001 From: GodCipher Date: Wed, 26 Jun 2024 18:10:09 +0200 Subject: [PATCH] Now logs the stacktrace when on async --- .../model/pathing/pathfinder/AbstractPathfinder.java | 5 ++--- .../src/main/java/org/patheloper/util/ErrorLogger.java | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java b/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java index bc2f3dad..2f5efe7e 100644 --- a/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java +++ b/pathetic-model/src/main/java/org/patheloper/model/pathing/pathfinder/AbstractPathfinder.java @@ -79,8 +79,7 @@ private SnapshotManager determineSnapshotManager( @NonNull PathPosition target, @Nullable List filters) { - if (filters == null) - filters = Collections.emptyList(); + if (filters == null) filters = Collections.emptyList(); raiseStartEvent(start, target, filters); @@ -139,7 +138,7 @@ private CompletionStage initiateAsyncPathing( try { return resolvePath(start, target, filters); } catch (Exception e) { - throw ErrorLogger.logFatalError("Failed to find path async", e); + throw ErrorLogger.logFatalErrorWithStacktrace("Failed to find path async", e); } }, PATHING_EXECUTOR) diff --git a/pathetic-model/src/main/java/org/patheloper/util/ErrorLogger.java b/pathetic-model/src/main/java/org/patheloper/util/ErrorLogger.java index c1157f05..61e1609b 100644 --- a/pathetic-model/src/main/java/org/patheloper/util/ErrorLogger.java +++ b/pathetic-model/src/main/java/org/patheloper/util/ErrorLogger.java @@ -20,7 +20,12 @@ public static IllegalStateException logFatalError(String message, Throwable caus log.error("OS: {}", System.getProperty("os.name")); log.error("OS Architecture: {}", System.getProperty("os.arch")); log.error("==============================="); - log.error("Stacktrace:", cause); return new IllegalStateException(message, cause); } + + public static IllegalStateException logFatalErrorWithStacktrace(String message, Throwable cause) { + IllegalStateException exception = logFatalError(message, cause); + log.error("Stacktrace:", cause); + return exception; + } }