Index: /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 14310)
+++ /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 14310)
+++ /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 14310)
+++ /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;
         }
Index: /trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java	(revision 14310)
+++ /trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java	(revision 14311)
@@ -14,4 +14,5 @@
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.commons.jcs.access.behavior.ICacheAccess;
@@ -145,5 +146,5 @@
     @Test
     public void testServiceExceptionPattern() {
-        test("missing parameters ['version', 'format']",
+        testServiceException("missing parameters ['version', 'format']",
                 "<?xml version=\"1.0\"?>\n" +
                 "<!DOCTYPE ServiceExceptionReport SYSTEM \"http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd\">\n" +
@@ -151,5 +152,5 @@
                 "    <ServiceException>missing parameters ['version', 'format']</ServiceException>\n" +
                 "</ServiceExceptionReport>");
-        test("Parameter 'layers' contains unacceptable layer names.",
+        testServiceException("Parameter 'layers' contains unacceptable layer names.",
                 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\r\n" +
                 "<!DOCTYPE ServiceExceptionReport SYSTEM \"http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd\">\r\n" +
@@ -162,6 +163,25 @@
     }
 
-    private static void test(String expected, String xml) {
-        Matcher m = TMSCachedTileLoaderJob.SERVICE_EXCEPTION_PATTERN.matcher(xml);
+    /**
+     * Tests that {@code TMSCachedTileLoaderJob#CDATA_PATTERN} is correct.
+     */
+    @Test
+    public void testCdataPattern() {
+        testCdata("received unsuitable wms request: no <grid> with suitable srs found for layer capitais",
+                "<![CDATA[\r\n" +
+                "received unsuitable wms request: no <grid> with suitable srs found for layer capitais\r\n" +
+                "]]>");
+    }
+
+    private static void testServiceException(String expected, String xml) {
+        test(TMSCachedTileLoaderJob.SERVICE_EXCEPTION_PATTERN, expected, xml);
+    }
+
+    private static void testCdata(String expected, String xml) {
+        test(TMSCachedTileLoaderJob.CDATA_PATTERN, expected, xml);
+    }
+
+    private static void test(Pattern pattern, String expected, String xml) {
+        Matcher m = pattern.matcher(xml);
         assertTrue(xml, m.matches());
         assertEquals(expected, Utils.strip(m.group(1)));
