Index: applications/editors/josm/plugins/imagerycache/src/org/openstreetmap/josm/plugins/imagerycache/OsmDBTilesLoader.java
===================================================================
--- applications/editors/josm/plugins/imagerycache/src/org/openstreetmap/josm/plugins/imagerycache/OsmDBTilesLoader.java	(revision 30737)
+++ applications/editors/josm/plugins/imagerycache/src/org/openstreetmap/josm/plugins/imagerycache/OsmDBTilesLoader.java	(revision 30738)
@@ -11,4 +11,5 @@
 import java.util.Map;
 import java.util.Random;
+
 import org.openstreetmap.gui.jmapviewer.JobDispatcher;
 import org.openstreetmap.gui.jmapviewer.OsmTileLoader;
@@ -20,24 +21,25 @@
 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource.TileUpdate;
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.preferences.BooleanProperty;
 
 /**
- * 
+ *
  * @author Alexei Kasatkin, based on OsmFileCacheTileLoader by @author Jan Peter Stotz, @author Stefan Zeller
  */
 class OsmDBTilesLoader extends OsmTileLoader implements CachedTileLoader {
-    
-    
+
+
     public static final long FILE_AGE_ONE_DAY = 1000 * 60 * 60 * 24;
     public static final long FILE_AGE_ONE_WEEK = FILE_AGE_ONE_DAY * 7;
-    
+
     public static final boolean debug = new BooleanProperty("imagerycache.debug", false).get();
-            
+
     TileDAOMapDB dao;
-   
+
     protected long maxCacheFileAge = FILE_AGE_ONE_WEEK;
     protected long recheckAfter = FILE_AGE_ONE_DAY;
 
-    
+
     public OsmDBTilesLoader(TileLoaderListener smap, File cacheFolder) {
         super(smap);
@@ -45,5 +47,5 @@
         dao.setCacheFolder(cacheFolder);
     }
-    
+
     @Override
     public TileJob createTileLoaderJob(final Tile tile) {
@@ -60,19 +62,19 @@
         dao.cleanStorage(source.getName());
     }
-    
+
     protected class DatabaseLoadJob implements TileJob {
 
         private final Tile tile;
         File tileCacheDir;
-        
+
         /**
-         * Stores the tile loaded from database, null if nothing found. 
+         * Stores the tile loaded from database, null if nothing found.
          */
         DBTile dbTile = null;
         long fileAge = 0;
-        
+
         long id;
         String sourceName;
-        
+
         public DatabaseLoadJob(Tile tile) {
             this.tile = tile;
@@ -112,5 +114,5 @@
 
         /**
-         * Loads tile from database. 
+         * Loads tile from database.
          * There can be dbTile != null but the tile is outdated and reload is still needed
          * @return true if no loading from server is needed.
@@ -120,8 +122,8 @@
             try {
                 dbTile = dao.getById(sourceName, id);
-                
+
                 if (dbTile == null) return false;
-                
-                loadMetadata(); 
+
+                loadMetadata();
                 if (debug) System.out.println(id+": found in cache, metadata ="+dbTile.metaData);
 
@@ -149,6 +151,6 @@
                 }
             } catch (Exception e) {
-                System.out.println("Error: Can not load tile from database: "+sourceName+":"+id);
-                e.printStackTrace(System.out);
+            	Main.error("Error: Can not load tile from database: "+sourceName+":"+id);
+            	Main.error(e);
                 try {
                     if (bin != null) {
@@ -161,7 +163,7 @@
                 return false; // tile is not because of some error (corrupted database, etc.)
             } catch (Error e) { // this is bad, bat MapDB throws it
-                System.out.println("Serious database error: Can not load tile from database: "+sourceName+":"+id);
-                e.printStackTrace(System.out);
-                dbTile = null;  fileAge = 0;  return false;                                            
+                Main.error("Serious database error: Can not load tile from database: "+sourceName+":"+id);
+            	Main.error(e);
+                dbTile = null;  fileAge = 0;  return false;
             }
         }
@@ -170,7 +172,7 @@
             return System.currentTimeMillis() - maxCacheFileAge + recheckAfter;
         }
-                
+
         private void loadOrUpdateTileFromServer() {
-            
+
             try {
                 URLConnection urlConn = loadTileFromOsm(tile);
@@ -195,5 +197,5 @@
                     dbTile = new DBTile();
                 }
-                
+
                 if (tileUpdate == TileSource.TileUpdate.ETag || tileUpdate == TileSource.TileUpdate.IfNoneMatch) {
                     String fileETag = tile.getValue("etag");
@@ -224,5 +226,5 @@
                 loadTileMetadata(tile, urlConn);
                 dbTile.metaData = tile.getMetadata();
-                
+
                 if ("no-tile".equals(tile.getValue("tile-info")))
                 {
@@ -248,5 +250,5 @@
                     }
                 }
-                
+
             } catch (Exception e) {
                 tile.setError(e.getMessage());
@@ -261,6 +263,6 @@
             }
         }
-        
-        
+
+
         protected byte[] loadTileInBuffer(URLConnection urlConn) throws IOException {
             InputStream input = urlConn.getInputStream();
@@ -292,5 +294,5 @@
          * </ul>
          *
-         * @param fileAge time of the 
+         * @param fileAge time of the
          * @return <code>true</code> if the tile on the server is newer than the
          *         file
