Index: /trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/AutosaveTask.java	(revision 10469)
@@ -187,5 +187,5 @@
                 }
             } catch (IOException e) {
-                Main.error(tr("IOError while creating file, autosave will be skipped: {0}", e.getMessage()));
+                Main.error(e, tr("IOError while creating file, autosave will be skipped: {0}", e.getMessage()));
                 return null;
             }
Index: /trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java	(revision 10469)
@@ -96,4 +96,15 @@
 
     /**
+     * Log an exception.
+     * @param e exception to log
+     * @param s message prefix
+     * @since 10469
+     */
+    public static void log(Exception e, String s) {
+        summary.append(s + ' ' + Main.getErrorMessage(e));
+        summary.append('\n');
+    }
+
+    /**
      * Returns the log.
      * @return the log
@@ -273,5 +284,5 @@
             root = document.getDocumentElement();
         } catch (SAXException | IOException | ParserConfigurationException ex) {
-            Main.warn("Error getting preferences to save:" +ex.getMessage());
+            Main.warn(ex, "Error getting preferences to save:");
         }
         if (root == null || exportDocument == null)
@@ -454,5 +465,5 @@
                 }
             } catch (ScriptException | IOException | SecurityException ex) {
-                log("Error reading custom preferences: " + ex.getMessage());
+                log(ex, "Error reading custom preferences:");
             }
         }
@@ -465,5 +476,5 @@
                 }
             } catch (SAXException | IOException | ParserConfigurationException ex) {
-                log("Error reading custom preferences: "+ex.getMessage());
+                log(ex, "Error reading custom preferences:");
             }
             log("-- Reading complete --");
@@ -580,5 +591,5 @@
                     // we store this fragment as API.fragments['id']
                 } catch (ScriptException ex) {
-                    log("Error: can not load preferences fragment : "+ex.getMessage());
+                    log(ex, "Error: can not load preferences fragment:");
                 }
             }
@@ -664,5 +675,5 @@
                 engine.eval(name+"='"+value+"';");
             } catch (ScriptException ex) {
-                log("Error: Can not assign variable: %s=%s  : %s\n", name, value, ex.getMessage());
+                log(ex, String.format("Error: Can not assign variable: %s=%s :", name, value));
             }
         }
@@ -707,5 +718,5 @@
             } catch (ScriptException ex) {
                 messageBox("e", ex.getMessage());
-                log("JS error: "+ex.getMessage());
+                log(ex, "JS error:");
             }
             log("Script finished");
@@ -725,5 +736,5 @@
                     mr.appendReplacement(sb, result);
                 } catch (ScriptException ex) {
-                    log("Error: Can not evaluate expression %s : %s", mr.group(1), ex.getMessage());
+                    log(ex, String.format("Error: Can not evaluate expression %s :", mr.group(1)));
                 }
             }
@@ -746,5 +757,5 @@
                 tmpPref.fromXML(reader);
             } catch (TransformerException | XMLStreamException | IOException ex) {
-                log("Error: can not read XML fragment :" + ex.getMessage());
+                log(ex, "Error: can not read XML fragment:");
             }
 
Index: /trunk/src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/Preferences.java	(revision 10469)
@@ -909,5 +909,5 @@
                     save();
                 } catch (IOException e) {
-                    Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
+                    Main.warn(e, tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile()));
                 }
             }
@@ -1251,5 +1251,5 @@
             struct = klass.getConstructor().newInstance();
         } catch (ReflectiveOperationException ex) {
-            throw new RuntimeException(ex);
+            throw new IllegalArgumentException(ex);
         }
         for (Entry<String, String> key_value : hash.entrySet()) {
@@ -1259,4 +1259,5 @@
                 f = klass.getDeclaredField(key_value.getKey().replace('-', '_'));
             } catch (NoSuchFieldException ex) {
+                Main.trace(ex);
                 continue;
             }
Index: /trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java	(revision 10469)
@@ -188,4 +188,12 @@
 
     /**
+     * @param error error related to this object
+     * @since 10469
+     */
+    public void setError(Exception error) {
+        setErrorMessage(Main.getErrorMessage(error));
+    }
+
+    /**
      * @param message error message related to this object
      */
Index: /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java	(revision 10469)
@@ -378,5 +378,5 @@
             log.log(Level.FINE, "JCS - Caching empty object as server returned 404 for: {0}", getUrlNoException());
             attributes.setResponseCode(404);
-            attributes.setErrorMessage(e.toString());
+            attributes.setError(e);
             boolean doCache = isResponseLoadable(null, 404, null) || cacheAsEmpty();
             if (doCache) {
@@ -387,5 +387,5 @@
         } catch (IOException e) {
             log.log(Level.FINE, "JCS - IOExecption during communication with server for: {0}", getUrlNoException());
-            attributes.setErrorMessage(e.toString());
+            attributes.setError(e);
             attributes.setResponseCode(499); // set dummy error code
             boolean doCache = isResponseLoadable(null, 499, null) || cacheAsEmpty(); //generic 499 error code returned
@@ -396,5 +396,5 @@
             return doCache;
         } catch (InterruptedException e) {
-            attributes.setErrorMessage(e.toString());
+            attributes.setError(e);
             log.log(Level.WARNING, "JCS - Exception during download {0}", getUrlNoException());
             Main.warn(e);
Index: /trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java	(revision 10469)
@@ -77,5 +77,5 @@
                         return ret;
                     } catch (IOException ex) {
-                        Main.warn("Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
+                        Main.warn(ex, "Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
                         Thread.sleep(waitTimeSec * 1000L);
                         waitTimeSec *= 2;
Index: /trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java	(revision 10469)
@@ -143,5 +143,5 @@
                 OnlineResource.JOSM_WEBSITE.checkOfflineAccess(source, Main.getJOSMWebsite());
             } catch (OfflineAccessException e) {
-                Main.warn(e.getMessage());
+                Main.warn(e, false);
                 online = false;
             }
Index: /trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java	(revision 10469)
@@ -210,5 +210,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.toString());
+            tile.setError(e);
             tile.setLoaded(false);
             if (listeners != null) { // listeners might be null, if some other thread notified already about success
Index: /trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java	(revision 10469)
@@ -19,4 +19,5 @@
 import java.util.concurrent.RecursiveTask;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.tools.Geometry;
 import org.openstreetmap.josm.tools.Geometry.PolygonIntersection;
@@ -144,4 +145,5 @@
             return makeFromPolygons(joinedWays);
         } catch (JoinedPolygonCreationException ex) {
+            Main.debug(ex);
             return ex.getMessage();
         }
Index: /trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java	(revision 10469)
@@ -875,5 +875,5 @@
             return SearchCompiler.compile(Main.pref.get(prefName, defaultValue));
         } catch (ParseError e) {
-            Main.error("Unable to compile pattern for " + prefName + ", trying default pattern: " + e.getMessage());
+            Main.error(e, "Unable to compile pattern for " + prefName + ", trying default pattern:");
         }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java	(revision 10469)
@@ -145,7 +145,5 @@
             // On read, it would first check, if the way still has firstIdx+2 nodes, then check if the corresponding way nodes are still
             // the same and report changes in a more controlled manner.
-            if (Main.isTraceEnabled()) {
-                Main.trace(e.getMessage());
-            }
+            Main.trace(e);
         }
     }
Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapRendererFactory.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapRendererFactory.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapRendererFactory.java	(revision 10469)
@@ -101,5 +101,5 @@
                 return Class.forName(className, true, cl);
             } catch (final NoClassDefFoundError | ClassNotFoundException e) {
-                Main.trace(e.getMessage());
+                Main.trace(e);
             }
         }
@@ -266,6 +266,5 @@
      * @see AbstractMapRenderer#AbstractMapRenderer(Graphics2D, NavigatableComponent, boolean)
      */
-    public AbstractMapRenderer createActiveRenderer(Graphics2D g, NavigatableComponent viewport, boolean isInactiveMode)
-            throws MapRendererFactoryException {
+    public AbstractMapRenderer createActiveRenderer(Graphics2D g, NavigatableComponent viewport, boolean isInactiveMode) {
         try {
             Constructor<?> c = activeRenderer.getConstructor(new Class<?>[]{Graphics2D.class, NavigatableComponent.class, boolean.class});
@@ -274,4 +273,5 @@
             throw new MapRendererFactoryException(e);
         } catch (InvocationTargetException e) {
+            Main.debug(e);
             throw new MapRendererFactoryException(e.getCause());
         }
Index: /trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java	(revision 10469)
@@ -205,4 +205,5 @@
             update(pref);
         } catch (ProjectionConfigurationException ex) {
+            Main.trace(ex);
             try {
                 update(null);
Index: /trunk/src/org/openstreetmap/josm/data/projection/Projections.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/projection/Projections.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/projection/Projections.java	(revision 10469)
@@ -324,6 +324,5 @@
                 proj = pc.getProjection();
             } catch (RuntimeException e) {
-                String cause = e.getMessage();
-                Main.warn("Unable to get projection "+code+" with "+pc + (cause != null ? ". "+cause : ""));
+                Main.warn(e, "Unable to get projection "+code+" with "+pc+':');
             }
         }
Index: /trunk/src/org/openstreetmap/josm/data/validation/TestError.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/TestError.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/validation/TestError.java	(revision 10469)
@@ -361,5 +361,5 @@
                 primitives = Collections.emptyList();
             } else {
-                Main.warn("Unable to remove primitives from "+this);
+                Main.warn(e, "Unable to remove primitives from "+this+'.');
             }
         }
Index: /trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/validation/tests/ConditionalKeys.java	(revision 10469)
@@ -13,4 +13,5 @@
 import java.util.regex.Pattern;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.validation.Severity;
@@ -141,4 +142,5 @@
             }
         } catch (ConditionalParsingException ex) {
+            Main.debug(ex);
             return ex.getMessage();
         }
Index: /trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java	(revision 10469)
@@ -7,4 +7,5 @@
 import java.util.regex.Pattern;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -107,4 +108,5 @@
                     error = doValidateTag(p, k, protocol+IDN.toASCII(domain)+ending, validator, code);
                 } catch (IllegalArgumentException e) {
+                    Main.trace(e);
                     error.setMessage(error.getMessage() +
                             tr(" URL cannot be converted to ASCII: {0}", e.getMessage()));
Index: /trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 10469)
@@ -301,5 +301,5 @@
                             check.errors.put(ai, severity);
                         } catch (IllegalArgumentException e) {
-                            Main.warn("Unsupported "+ai.key+" instruction. Allowed instructions are "+POSSIBLE_THROWS);
+                            Main.warn(e, "Unsupported "+ai.key+" instruction. Allowed instructions are "+POSSIBLE_THROWS+'.');
                         }
                     } else if ("fixAdd".equals(ai.key)) {
@@ -436,7 +436,5 @@
                 }
             } catch (IndexOutOfBoundsException ignore) {
-                if (Main.isDebugEnabled()) {
-                    Main.debug(ignore.getMessage());
-                }
+                Main.debug(ignore);
             }
             return null;
@@ -466,5 +464,5 @@
                     m.appendReplacement(sb, String.valueOf(argument).replace("^(", "").replace(")$", ""));
                 } catch (IndexOutOfBoundsException | IllegalArgumentException e) {
-                    Main.error(tr("Unable to replace argument {0} in {1}: {2}", argument, sb, e.getMessage()));
+                    Main.error(e, tr("Unable to replace argument {0} in {1}: {2}", argument, sb, e.getMessage()));
                 }
             }
Index: /trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java	(revision 10468)
+++ /trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java	(revision 10469)
@@ -245,4 +245,5 @@
                 }
             } catch (IOException e) {
+                Main.error(e);
                 errorSources.append(source).append('\n');
             }
@@ -294,5 +295,5 @@
                 harmonizedKeys.put(harmonizeKey(ky.key), ky.key);
             } catch (NullPointerException e) {
-                Main.error(p+": Unable to initialize "+ky);
+                Main.error(e, p+": Unable to initialize "+ky+'.');
             }
         }
@@ -783,4 +784,5 @@
                 }
             } catch (IllegalStateException e) {
+                Main.error(e);
                 description = null;
             }
@@ -825,6 +827,8 @@
                     data.add(new CheckerElement(exp));
                 } catch (IllegalStateException e) {
+                    Main.trace(e);
                     return tr("Illegal expression ''{0}''", exp);
                 } catch (PatternSyntaxException e) {
+                    Main.trace(e);
                     return tr("Illegal regular expression ''{0}''", exp);
                 }
