Ignore:
Timestamp:
2016-08-24T00:18:37+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #13434 - Increase bug report test coverage (patch by michael2402) - gsoc-core

Location:
trunk/src/org/openstreetmap/josm/tools/bugreport
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReport.java

    r10745 r10886  
    123123        PrintWriter out = new PrintWriter(stringWriter);
    124124        if (isIncludeStatusReport()) {
    125             out.println(ShowStatusReportAction.getReportHeader());
     125            try {
     126                out.println(ShowStatusReportAction.getReportHeader());
     127            } catch (RuntimeException e) {
     128                out.println("Could not generate status report: " + e.getMessage());
     129            }
    126130        }
    127131        if (isIncludeData()) {
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportQueue.java

    r10819 r10886  
    55import java.util.ArrayList;
    66import java.util.LinkedList;
     7import java.util.concurrent.CopyOnWriteArrayList;
    78import java.util.function.BiFunction;
     9import java.util.function.Predicate;
    810
    911import org.openstreetmap.josm.Main;
     
    2325    private Thread displayThread;
    2426    private final BiFunction<ReportedException, Integer, SuppressionMode> bugReportHandler = getBestHandler();
     27    private final CopyOnWriteArrayList<Predicate<ReportedException>> handlers = new CopyOnWriteArrayList<>();
    2528    private int displayedErrors;
    2629
     
    97100
    98101    private SuppressionMode displayFor(ReportedException e) {
     102        if (handlers.stream().anyMatch(p -> p.test(e))) {
     103            Main.trace("Intercepted by handler.");
     104            return SuppressionMode.NONE;
     105        }
    99106        return bugReportHandler.apply(e, getDisplayedErrors());
    100107    }
     
    123130    }
    124131
     132    /**
     133     * Allows you to peek or even intersect the bug reports.
     134     * @param handler The handler. It can return false to stop all further handling of the exception.
     135     * @since 10886
     136     */
     137    public void addBugReportHandler(Predicate<ReportedException> handler) {
     138        handlers.add(handler);
     139    }
     140
     141    /**
     142     * Gets the global bug report queue
     143     * @return The queue
     144     * @since 10886
     145     */
    125146    public static BugReportQueue getInstance() {
    126147        return INSTANCE;
Note: See TracChangeset for help on using the changeset viewer.