Skip to content

Commit 113c617

Browse files
committed
ModuleRunner: only log unhandled errors
If someone wants to subscribe to ModuleErroredEvent and handle it, they can now consume the event to prevent it from being logged.
1 parent 3b6c40a commit 113c617

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/org/scijava/module/ModuleRunner.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,12 @@ private void cleanupAndBroadcastCancelation(final String title,
200200
private void cleanupAndBroadcastException(final String title,
201201
final Throwable t)
202202
{
203-
if (es != null) es.publish(new ModuleErroredEvent(module, t));
204-
if (log != null) log.error("Command errored: " + title, t);
203+
final ModuleErroredEvent evt = new ModuleErroredEvent(module, t);
204+
if (es != null) es.publish(evt);
205+
if (log != null && !evt.isConsumed()) {
206+
// Nothing else handled the error, so log it.
207+
log.error("Command errored: " + title, t);
208+
}
205209
}
206210

207211
private boolean isCanceled() {

0 commit comments

Comments
 (0)