001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.plugins;
003
004import static org.openstreetmap.josm.tools.I18n.tr;
005
006/**
007 * Exception that wraps any exception thrown by plugins. It is used in the JOSM main system
008 * and there is no particular reason to use this within the plugin itself (although there
009 * is also no reason against this.. ;)
010 *
011 * @author Immanuel.Scholz
012 */
013public class PluginException extends Exception {
014    public final transient PluginProxy plugin;
015    public final String name;
016
017    public PluginException(PluginProxy plugin, String name, Throwable cause) {
018        super(tr("An error occurred in plugin {0}", name), cause);
019        this.plugin = plugin;
020        this.name = name;
021    }
022
023    public PluginException(String name, String message) {
024        super(message);
025        this.plugin = null;
026        this.name = name;
027    }
028
029    public PluginException(String name, Throwable cause) {
030        super(tr("An error occurred in plugin {0}", name), cause);
031        this.plugin = null;
032        this.name = name;
033    }
034}