diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java index a496cd3999cddde230154c01fdf26367ee13ccd7..1fd11912652a1341974575510f5d095f3ac84c3a 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHandler.java @@ -72,8 +72,9 @@ public class ConfigClientsHandler extends FormHandler { PluginStarter.stopPlugin(_context, app); PluginStarter.deletePlugin(_context, app); addFormNotice(_("Deleted plugin {0}", app)); - } catch (IOException e) { + } catch (Throwable e) { addFormError(_("Error deleting plugin {0}", app) + ": " + e); + _log.error("Error deleting plugin " + app, e); } } return; @@ -84,8 +85,11 @@ public class ConfigClientsHandler extends FormHandler { String app = _action.substring(5); try { PluginStarter.stopPlugin(_context, app); - } catch (IOException e) {} - addFormNotice(_("Stopped plugin {0}", app)); + addFormNotice(_("Stopped plugin {0}", app)); + } catch (Throwable e) { + addFormError(_("Error stopping plugin {0}", app) + ": " + e); + _log.error("Error stopping plugin " + app, e); + } return; } @@ -247,8 +251,9 @@ public class ConfigClientsHandler extends FormHandler { path = new File(path, app + ".war"); WebAppStarter.startWebApp(_context, s, app, path.getAbsolutePath()); addFormNotice(_("WebApp") + " <a href=\"/" + app + "/\">" + _(app) + "</a> " + _("started") + '.'); - } catch (Exception ioe) { - addFormError(_("Failed to start") + ' ' + _(app) + " " + ioe + '.'); + } catch (Throwable e) { + addFormError(_("Failed to start") + ' ' + _(app) + " " + e + '.'); + _log.error("Failed to start webapp " + app, e); } return; } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java index d0daac4b2e49473d35c76a94a76f9f317816d7f9..a096df5f0895e22cffce558c857878a585118564 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/ConfigClientsHelper.java @@ -181,7 +181,7 @@ public class ConfigClientsHelper extends HelperBase { if (showEditButton && (!edit) && !ro) buf.append("<button type=\"submit\" name=\"edit\" value=\"Edit ").append(index).append("\" >" + _("Edit") + "<span class=hide> ").append(index).append("</span></button>"); if (showStopButton && (!edit)) - buf.append("<button type=\"submit\" name=\"edit\" value=\"Stop ").append(index).append("\" >" + _("Stop") + "<span class=hide> ").append(index).append("</span></button>"); + buf.append("<button type=\"submit\" name=\"action\" value=\"Stop ").append(index).append("\" >" + _("Stop") + "<span class=hide> ").append(index).append("</span></button>"); if (showUpdateButton && (!edit) && !ro) { buf.append("<button type=\"submit\" name=\"action\" value=\"Check ").append(index).append("\" >" + _("Check for updates") + "<span class=hide> ").append(index).append("</span></button>"); buf.append("<button type=\"submit\" name=\"action\" value=\"Update ").append(index).append("\" >" + _("Update") + "<span class=hide> ").append(index).append("</span></button>"); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java index c6dd398cbb689f1a9b752c59ab0bb86c8fc2d948..76920fc68bc0270fd32ac27ab7b057ff8789cd03 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginStarter.java @@ -50,6 +50,7 @@ public class PluginStarter implements Runnable { startPlugins(_context); } + /** this shouldn't throw anything */ static void startPlugins(RouterContext ctx) { Log log = ctx.logManager().getLog(PluginStarter.class); Properties props = pluginProperties(); @@ -61,7 +62,7 @@ public class PluginStarter implements Runnable { try { if (!startPlugin(ctx, app)) log.error("Failed to start plugin: " + app); - } catch (Exception e) { + } catch (Throwable e) { log.error("Failed to start plugin: " + app, e); } } @@ -69,7 +70,10 @@ public class PluginStarter implements Runnable { } } - /** @return true on success */ + /** + * @return true on success + * @throws just about anything, caller would be wise to catch Throwable + */ static boolean startPlugin(RouterContext ctx, String appName) throws Exception { Log log = ctx.logManager().getLog(PluginStarter.class); File pluginDir = new File(ctx.getAppDir(), PluginUpdateHandler.PLUGIN_DIR + '/' + appName); @@ -159,7 +163,10 @@ public class PluginStarter implements Runnable { return true; } - /** @return true on success */ + /** + * @return true on success + * @throws just about anything, caller would be wise to catch Throwable + */ static boolean stopPlugin(RouterContext ctx, String appName) throws IOException { Log log = ctx.logManager().getLog(PluginStarter.class); File pluginDir = new File(ctx.getAppDir(), PluginUpdateHandler.PLUGIN_DIR + '/' + appName); diff --git a/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java index 903000fbd797cf28144502ac55f43b754745a889..46ff441cb328cf96159b0b9e10f9d2f3c442cb2d 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/PluginUpdateHandler.java @@ -308,7 +308,10 @@ public class PluginUpdateHandler extends UpdateHandler { if (!PluginStarter.stopPlugin(_context, appName)) { // failed, ignore } - } catch (IOException e) {} // ignore + } catch (Throwable e) { + // no updateStatus() for this one + _log.error("Error stopping plugin " + appName, e); + } } else { if (Boolean.valueOf(props.getProperty("update-only")).booleanValue()) { @@ -347,8 +350,9 @@ public class PluginUpdateHandler extends UpdateHandler { updateStatus("<b>" + _("Plugin {0} installed and started", appName) + "</b>"); else updateStatus("<b>" + _("Plugin {0} installed but failed to start, check logs", appName) + "</b>"); - } catch (Exception e) { + } catch (Throwable e) { updateStatus("<b>" + _("Plugin {0} installed but failed to start", appName) + ": " + e + "</b>"); + _log.error("Error starting plugin " + appName, e); } } } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java b/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java index 3e24a38c41a6068bfeafc2268bca826f6f7dab04..1117fd93abdaaa9e2ba7574a6231cd913a805aa0 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/WebAppStarter.java @@ -30,6 +30,7 @@ public class WebAppStarter { /** * adds and starts + * @throws just about anything, caller would be wise to catch Throwable */ static void startWebApp(I2PAppContext ctx, Server server, String appName, String warPath) throws Exception { File tmpdir = new File(ctx.getTempDir(), "jetty-work-" + appName + ctx.random().nextInt()); @@ -61,6 +62,7 @@ public class WebAppStarter { /** * stop it + * @throws just about anything, caller would be wise to catch Throwable */ static void stopWebApp(Server server, String appName) { // this will return a new context if one does not exist