Index: trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 13229)
+++ trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 13230)
@@ -16,4 +16,6 @@
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.commons.jcs.access.behavior.ICacheAccess;
@@ -50,4 +52,12 @@
     protected static final long ABSOLUTE_EXPIRE_TIME_LIMIT = TimeUnit.DAYS.toMillis(365);
 
+    // Pattern to detect Tomcat error message. Be careful with change of format:
+    // CHECKSTYLE.OFF: LineLength
+    // https://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/ErrorReportValve.java?r1=1740707&r2=1779641&pathrev=1779641&diff_format=h
+    // CHECKSTYLE.ON: LineLength
+    protected static final Pattern TOMCAT_ERR_MESSAGE = Pattern.compile(
+        ".*<p><b>[^<]+</b>[^<]+</p><p><b>[^<]+</b> (?:<u>)?([^<]*)(?:</u>)?</p><p><b>[^<]+</b> (?:<u>)?[^<]*(?:</u>)?</p>.*",
+        Pattern.CASE_INSENSITIVE);
+
     /**
      * maximum download threads that will be started
@@ -74,6 +84,4 @@
             Utils.newThreadFactory("JCS-downloader-%d", Thread.NORM_PRIORITY)
             );
-
-
 
     private static final ConcurrentMap<String, Set<ICachedLoaderListener>> inProgress = new ConcurrentHashMap<>();
@@ -359,4 +367,15 @@
                 } else {
                     raw = new byte[]{};
+                    try {
+                        String data = urlConn.fetchContent();
+                        if (!data.isEmpty()) {
+                            Matcher m = TOMCAT_ERR_MESSAGE.matcher(data);
+                            if (m.matches()) {
+                                attributes.setErrorMessage(m.group(1).replace("'", "''"));
+                            }
+                        }
+                    } catch (IOException e) {
+                        Logging.warn(e);
+                    }
                 }
 
@@ -390,5 +409,5 @@
             return doCache;
         } catch (IOException e) {
-            Logging.debug("JCS - IOExecption during communication with server for: {0}", getUrlNoException());
+            Logging.debug("JCS - IOException during communication with server for: {0}", getUrlNoException());
             if (isObjectLoadable()) {
                 return true;
