From: David Paleino <dapal@debian.org>
Subject: backport fixed failed authorisation dialog from 4021
Origin: vendor
Forwarded: not-needed

---
 src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java |    3 +-
 src/org/openstreetmap/josm/tools/ExceptionUtil.java     |   24 ++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

--- josm.orig/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
+++ josm/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
@@ -271,9 +271,10 @@ public class ExceptionDialogUtil {
      * @param e the exception
      */
     public static void explainAuthorizationFailed(OsmApiException e) {
+        // Fixme: add special handling that calls ExceptionUtil.explainFailedOAuthAuthorisation(e)
         HelpAwareOptionPane.showOptionDialog(
                 Main.parent,
-                ExceptionUtil.explainFailedOAuthAuthorisation(e),
+                ExceptionUtil.explainFailedAuthorisation(e),
                 tr("Authorisation Failed"),
                 JOptionPane.ERROR_MESSAGE,
                 ht("/ErrorMessages#AuthenticationFailed")
--- josm.orig/src/org/openstreetmap/josm/tools/ExceptionUtil.java
+++ josm/src/org/openstreetmap/josm/tools/ExceptionUtil.java
@@ -128,6 +128,30 @@ public class ExceptionUtil {
         );
     }
 
+   public static String explainFailedAuthorisation(OsmApiException e) {
+        e.printStackTrace();
+        String header = e.getErrorHeader();
+        String body = e.getErrorBody();
+        String msg = null;
+        if (header != null) {
+            if (body != null && !header.equals(body)) {
+                msg = header + " (" + body + ")";
+            } else {
+                msg = header;
+            }
+        } else {
+            msg = body;
+        }
+
+        return tr("<html>"
+                + "Authorisation at the OSM server failed.<br>"
+                + "The server reported the following error:<br>"
+                + "''{0}''"
+                + "</html>",
+                msg
+        );
+    }
+
     public static String explainFailedOAuthAuthorisation(OsmApiException e) {
         e.printStackTrace();
         return tr("<html>"
