CAMEL-7637 Avoid null throwable message when creating the 
FailedToCreateRouteException


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/dd89d6b8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/dd89d6b8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/dd89d6b8

Branch: refs/heads/camel-2.12.x
Commit: dd89d6b88072e6dba7e952728ea0a71db189ded0
Parents: 7400219
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Fri Jul 25 14:42:14 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Fri Jul 25 14:57:04 2014 +0800

----------------------------------------------------------------------
 .../org/apache/camel/FailedToCreateRouteException.java    | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/dd89d6b8/camel-core/src/main/java/org/apache/camel/FailedToCreateRouteException.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/FailedToCreateRouteException.java 
b/camel-core/src/main/java/org/apache/camel/FailedToCreateRouteException.java
index df63115..639384c 100644
--- 
a/camel-core/src/main/java/org/apache/camel/FailedToCreateRouteException.java
+++ 
b/camel-core/src/main/java/org/apache/camel/FailedToCreateRouteException.java
@@ -26,7 +26,7 @@ public class FailedToCreateRouteException extends 
CamelException {
     private final String routeId;
 
     public FailedToCreateRouteException(String routeId, String route, 
Throwable cause) {
-        super("Failed to create route " + routeId + ": " + 
getRouteMessage(route) + " because of " + cause.getMessage(), cause);
+        super("Failed to create route " + routeId + ": " + 
getRouteMessage(route) + " because of " + getExceptionMessage(cause), cause);
         this.routeId = routeId;
     }
 
@@ -38,6 +38,14 @@ public class FailedToCreateRouteException extends 
CamelException {
     public String getRouteId() {
         return routeId;
     }
+    
+    protected static String getExceptionMessage(Throwable cause) {
+        if (cause.getMessage() != null) {
+            return cause.getMessage();
+        } else {
+            return cause.getClass().getSimpleName();
+        }
+    }
 
     protected static String getRouteMessage(String route) {
         // cut the route after 60 chars so it won't be too big in the message

Reply via email to