Ticket #21214: 21214.show_bug_report_window_for_worker_thread_exceptions.patch

File 21214.show_bug_report_window_for_worker_thread_exceptions.patch, 1.7 KB (added by taylor.smock, 3 years ago)

If no graphics environment OR if logging level is set to debug, print stack trace for exception. Also, show the bug report window if logging level is set to debug.

  • src/org/openstreetmap/josm/gui/progress/swing/ProgressMonitorExecutor.java

    diff --git a/src/org/openstreetmap/josm/gui/progress/swing/ProgressMonitorExecutor.java b/src/org/openstreetmap/josm/gui/progress/swing/ProgressMonitorExecutor.java
    index 2a4a84765f..d0b04127a2 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.progress.swing;
    33
     4import java.awt.GraphicsEnvironment;
    45import java.util.concurrent.CancellationException;
    56import java.util.concurrent.ExecutionException;
    67import java.util.concurrent.Future;
    import java.util.concurrent.TimeUnit;  
    1011
    1112import org.openstreetmap.josm.tools.Logging;
    1213import org.openstreetmap.josm.tools.Utils;
     14import org.openstreetmap.josm.tools.bugreport.BugReport;
    1315
    1416/**
    1517 * Executor that displays the progress monitor to the user.
    public class ProgressMonitorExecutor extends ThreadPoolExecutor {  
    5860        }
    5961        if (t != null) {
    6062            Logging.error("Thread {0} raised {1}", Thread.currentThread().getName(), t);
     63            // Assume that a no graphics environment should *always* print the stack trace (these are almost always
     64            // test environments). Also log if trace is enabled.
     65            if (GraphicsEnvironment.isHeadless() || Logging.isDebugEnabled()) {
     66                Logging.error(t);
     67            }
     68            // For now, only show the user bug report windows when debug is enabled
     69            if (Logging.isDebugEnabled() || Utils.isRunningWebStart()) {
     70                BugReport.intercept(t).warn();
     71            }
    6172        }
    6273    }
    6374}