Ignore:
Timestamp:
2015-10-27T14:47:00+01:00 (8 years ago)
Author:
Don-vip
Message:

better detection of plugin loading failures for unit test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginProxy.java

    r8510 r8953  
    1919public class PluginProxy extends Plugin {
    2020
     21    /**
     22     * The plugin.
     23     */
    2124    public final Object plugin;
    2225
     26    /**
     27     * Constructs a new {@code PluginProxy}.
     28     * @param plugin the plugin
     29     * @param info the associated plugin info
     30     */
    2331    public PluginProxy(Object plugin, PluginInformation info) {
    2432        super(info);
     
    2634    }
    2735
    28     @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     36    private void handlePluginException(Exception e) {
     37        PluginHandler.pluginLoadingExceptions.put(getPluginInformation().name, e);
     38        BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
     39    }
     40
     41    @Override
     42    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    2943        try {
    3044            plugin.getClass().getMethod("mapFrameInitialized", MapFrame.class, MapFrame.class).invoke(plugin, oldFrame, newFrame);
     
    3246            Main.debug("Plugin "+plugin+" does not define mapFrameInitialized");
    3347        } catch (Exception e) {
    34             BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
     48            handlePluginException(e);
    3549        }
    3650    }
    3751
    38     @Override public PreferenceSetting getPreferenceSetting() {
     52    @Override
     53    public PreferenceSetting getPreferenceSetting() {
    3954        try {
    4055            return (PreferenceSetting) plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin);
     
    4358            return null;
    4459        } catch (Exception e) {
    45             BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
     60            handlePluginException(e);
    4661        }
    4762        return null;
    4863    }
    4964
    50     @Override public void addDownloadSelection(List<DownloadSelection> list) {
     65    @Override
     66    public void addDownloadSelection(List<DownloadSelection> list) {
    5167        try {
    5268            plugin.getClass().getMethod("addDownloadSelection", List.class).invoke(plugin, list);
     
    5470            Main.debug("Plugin "+plugin+" does not define addDownloadSelection");
    5571        } catch (Exception e) {
    56             BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
     72            handlePluginException(e);
    5773        }
    5874    }
Note: See TracChangeset for help on using the changeset viewer.