Index: /trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java	(revision 8605)
+++ /trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java	(revision 8606)
@@ -28,4 +28,5 @@
     private static final String EXPIRATION_TIME = "expirationTime";
     private static final String HTTP_RESPONSE_CODE = "httpResponceCode";
+    private static final String ERROR_MESSAGE = "errorMessage";
     // this contains all of the above
     private static final Set<String> RESERVED_KEYS = new HashSet<>(Arrays.asList(new String[]{
@@ -34,6 +35,8 @@
         LAST_MODIFICATION,
         EXPIRATION_TIME,
-        HTTP_RESPONSE_CODE
+        HTTP_RESPONSE_CODE,
+        ERROR_MESSAGE
     }));
+
 
     /**
@@ -176,3 +179,17 @@
         return Collections.unmodifiableMap(attrs);
     }
+
+    /**
+     * @return error message returned while retrieving this object
+     */
+    public String getErrorMessage() {
+        return attrs.get(ERROR_MESSAGE);
+    }
+
+    /**
+     * @param message error message related to this object
+     */
+    public void setErrorMessage(String message) {
+        attrs.put(ERROR_MESSAGE, message);
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 8605)
+++ /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 8606)
@@ -369,4 +369,5 @@
             log.log(Level.FINE, "JCS - Caching empty object as server returned 404 for: {0}", getUrl());
             attributes.setResponseCode(404);
+            attributes.setErrorMessage(e.toString());
             boolean doCache = isResponseLoadable(null, 404, null) || cacheAsEmpty();
             if (doCache) {
@@ -377,5 +378,5 @@
         } catch (IOException e) {
             log.log(Level.FINE, "JCS - IOExecption during communication with server for: {0}", getUrl());
-
+            attributes.setErrorMessage(e.toString());
             attributes.setResponseCode(499); // set dummy error code
             boolean doCache = isResponseLoadable(null, 499, null) || cacheAsEmpty(); //generic 499 error code returned
@@ -386,4 +387,5 @@
             return doCache;
         } catch (Exception e) {
+            attributes.setErrorMessage(e.toString());
             log.log(Level.WARNING, "JCS - Exception during download {0}",  getUrl());
             Main.warn(e);
Index: /trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 8605)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 8606)
@@ -188,6 +188,10 @@
                     }
                     int httpStatusCode = attributes.getResponseCode();
-                    if (!isNoTileAtZoom() && httpStatusCode >= 400) {
-                        tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
+                    if (!isNoTileAtZoom() && httpStatusCode >= 400 && httpStatusCode != 499) {
+                        if (attributes.getErrorMessage() == null) {
+                            tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
+                        } else {
+                            tile.setError(tr("Error downloading tiles: {0}", attributes.getErrorMessage()));
+                        }
                         status = false;
                     }
@@ -209,5 +213,5 @@
         } catch (IOException e) {
             LOG.log(Level.WARNING, "JCS TMS - error loading object for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()});
-            tile.setError(e.getMessage());
+            tile.setError(e.toString());
             tile.setLoaded(false);
             if (listeners != null) { // listeners might be null, if some other thread notified already about success
@@ -285,6 +289,8 @@
                     tile.finishLoading();
                 }
-                if (attributes.getResponseCode() >= 400) {
+                if (attributes.getErrorMessage() == null) {
                     tile.setError(tr("HTTP error {0} when loading tiles", attributes.getResponseCode()));
+                } else {
+                    tile.setError(tr("Error downloading tiles: {0}", attributes.getErrorMessage()));
                 }
                 return tile;
Index: /trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java	(revision 8605)
+++ /trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java	(revision 8606)
@@ -15,10 +15,9 @@
 public class JCSCachedTileLoaderJobTest {
     private static class TestCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, CacheEntry> {
+        private String url;
 
-        private int responseCode;
-
-        public TestCachedTileLoaderJob(int responseCode) throws IOException {
+        public TestCachedTileLoaderJob(String url) throws IOException {
             super(getCache(), 30000, 30000, null);
-            this.responseCode = responseCode;
+            this.url = url;
         }
 
@@ -35,5 +34,5 @@
         public URL getUrl() {
             try {
-                return new URL("http://httpstat.us/" + Integer.toString(responseCode));
+                return new URL(url);
             } catch (MalformedURLException e) {
                 throw new RuntimeException(e);
@@ -86,6 +85,19 @@
     }
 
+    @Test
+    public void testUnkownHost() throws Exception {
+        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob("http://unkownhost.unkownhost/unkown");
+        Listener listener = new Listener();
+        job.submit(listener, true);
+        synchronized (listener) {
+            if (!listener.ready) {
+                listener.wait();
+            }
+        }
+        assertEquals("java.net.UnknownHostException: unkownhost.unkownhost", listener.attributes.getErrorMessage());
+    }
+
     public void testStatusCode(int responseCode) throws Exception {
-        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(responseCode);
+        TestCachedTileLoaderJob job = getStatusLoaderJob(responseCode);
         Listener listener = new Listener();
         job.submit(listener, true);
@@ -98,4 +110,9 @@
 
     }
+
+    private static TestCachedTileLoaderJob getStatusLoaderJob(int responseCode) throws IOException {
+        return new TestCachedTileLoaderJob("http://httpstat.us/" + responseCode);
+    }
+
 }
 
