1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.plugins;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Exception that wraps any exception thrown by plugins. It is used in the JOSM main system
|
---|
8 | * and there is no particular reason to use this within the plugin itself (although there
|
---|
9 | * is also no reason against this.. ;)
|
---|
10 | *
|
---|
11 | * @author Immanuel.Scholz
|
---|
12 | * @since 149
|
---|
13 | */
|
---|
14 | public class PluginException extends Exception {
|
---|
15 |
|
---|
16 | /** Plugin proxy, can be null */
|
---|
17 | public final transient PluginProxy plugin;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Constructs a new {@code PluginException} with the specified plugin and cause.
|
---|
21 | * @param plugin plugin proxy
|
---|
22 | * @param name plugin name
|
---|
23 | * @param cause cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
|
---|
24 | */
|
---|
25 | public PluginException(PluginProxy plugin, String name, Throwable cause) {
|
---|
26 | super(tr("An error occurred in plugin {0}", name), cause);
|
---|
27 | this.plugin = plugin;
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Constructs a new {@code PluginException} with the specified detail message.
|
---|
32 | * @param message message the detail message (which is saved for later retrieval by the {@link #getMessage()} method).
|
---|
33 | */
|
---|
34 | public PluginException(String message) {
|
---|
35 | super(message);
|
---|
36 | this.plugin = null;
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Constructs a new {@code PluginException} with the specified plugin name, cause and a detail message of
|
---|
41 | * <code>(cause==null ? null : cause.toString())</code> (which typically contains the class and detail message of <code>cause</code>).
|
---|
42 | * @param name plugin name
|
---|
43 | * @param cause cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
|
---|
44 | */
|
---|
45 | public PluginException(String name, Throwable cause) {
|
---|
46 | super(tr("An error occurred in plugin {0}", name), cause);
|
---|
47 | this.plugin = null;
|
---|
48 | }
|
---|
49 | }
|
---|