Index: trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 14306)
+++ trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 14311)
@@ -360,7 +360,7 @@
                         String data = urlConn.fetchContent();
                         if (!data.isEmpty()) {
-                            Matcher m = HttpClient.getTomcatErrorMatcher(data);
-                            if (m.matches()) {
-                                attributes.setErrorMessage(m.group(1).replace("'", "''"));
+                            String detectErrorMessage = detectErrorMessage(data);
+                            if (detectErrorMessage != null) {
+                                attributes.setErrorMessage(detectErrorMessage);
                             }
                         }
@@ -418,4 +418,9 @@
         Logging.warn("JCS - Silent failure during download: {0}", getUrlNoException());
         return false;
+    }
+
+    protected String detectErrorMessage(String data) {
+        Matcher m = HttpClient.getTomcatErrorMatcher(data);
+        return m.matches() ? m.group(1).replace("'", "''") : null;
     }
 
Index: trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 14306)
+++ trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 14311)
@@ -50,4 +50,5 @@
     public static final LongProperty MINIMUM_EXPIRES = new LongProperty("imagery.generic.minimum_expires", TimeUnit.HOURS.toMillis(1));
     static final Pattern SERVICE_EXCEPTION_PATTERN = Pattern.compile("(?s).+<ServiceException[^>]*>(.+)</ServiceException>.+");
+    static final Pattern CDATA_PATTERN = Pattern.compile("(?s)\\s*<!\\[CDATA\\[(.+)\\]\\]>\\s*");
     protected final Tile tile;
     private volatile URL url;
@@ -318,3 +319,14 @@
         return true;
     }
+
+    @Override
+    protected String detectErrorMessage(String data) {
+        Matcher m = SERVICE_EXCEPTION_PATTERN.matcher(data);
+        return m.matches() ? removeCdata(Utils.strip(m.group(1))) : super.detectErrorMessage(data);
+    }
+
+    private static String removeCdata(String msg) {
+        Matcher m = CDATA_PATTERN.matcher(msg);
+        return m.matches() ? Utils.strip(m.group(1)) : msg;
+    }
 }
Index: trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 14306)
+++ trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 14311)
@@ -1167,5 +1167,9 @@
 
         if (tile.hasError() && getDisplaySettings().isShowErrors()) {
-            myDrawString(g, tr("Error") + ": " + tr(tile.getErrorMessage()), x + 2, texty);
+            String errorMessage = tr(tile.getErrorMessage());
+            if (errorMessage != null && !errorMessage.startsWith("Error") && !errorMessage.startsWith(tr("Error"))) {
+                errorMessage = tr("Error") + ": " + errorMessage;
+            }
+            myDrawString(g, errorMessage, x + 2, texty);
             //texty += 1 + fontHeight;
         }
