From e60d556d025fd6fa42ae1e819249ec2b41ee5fe3 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 9 Jan 2014 08:53:18 -0800 Subject: [PATCH] Better handling of LauncherException in error dialogs. --- .../com/skcraft/launcher/swing/SwingHelper.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/skcraft/launcher/swing/SwingHelper.java b/src/main/java/com/skcraft/launcher/swing/SwingHelper.java index dc072a1..2d1a2ad 100644 --- a/src/main/java/com/skcraft/launcher/swing/SwingHelper.java +++ b/src/main/java/com/skcraft/launcher/swing/SwingHelper.java @@ -9,6 +9,7 @@ package com.skcraft.launcher.swing; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.skcraft.launcher.LauncherException; import com.skcraft.launcher.util.SwingExecutor; import lombok.NonNull; import lombok.extern.java.Log; @@ -351,9 +352,15 @@ public final class SwingHelper { return; } - String message = t.getLocalizedMessage(); - if (message == null) { - message = _("errors.genericError"); + String message; + if (t instanceof LauncherException) { + message = t.getLocalizedMessage(); + t = t.getCause(); + } else { + message = t.getLocalizedMessage(); + if (message == null) { + message = _("errors.genericError"); + } } log.log(Level.WARNING, "Task failed", t); SwingHelper.showErrorDialog(owner, message, _("errorTitle"), t);