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 * @since 149 013 */ 014public class PluginException extends Exception { 015 016 /** Plugin proxy, can be null */ 017 public final transient PluginProxy plugin; 018 019 /** 020 * Constructs a new {@code PluginException} with the specified plugin and cause. 021 * @param plugin plugin proxy 022 * @param name plugin name 023 * @param cause cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 024 */ 025 public PluginException(PluginProxy plugin, String name, Throwable cause) { 026 super(tr("An error occurred in plugin {0}", name), cause); 027 this.plugin = plugin; 028 } 029 030 /** 031 * Constructs a new {@code PluginException} with the specified detail message. 032 * @param message message the detail message (which is saved for later retrieval by the {@link #getMessage()} method). 033 */ 034 public PluginException(String message) { 035 super(message); 036 this.plugin = null; 037 } 038 039 /** 040 * Constructs a new {@code PluginException} with the specified plugin name, cause and a detail message of 041 * <code>(cause==null ? null : cause.toString())</code> (which typically contains the class and detail message of <code>cause</code>). 042 * @param name plugin name 043 * @param cause cause the cause (which is saved for later retrieval by the {@link #getCause()} method). 044 */ 045 public PluginException(String name, Throwable cause) { 046 super(tr("An error occurred in plugin {0}", name), cause); 047 this.plugin = null; 048 } 049}