Repository: camel Updated Branches: refs/heads/master cfd8ad0ba -> 2c0151256
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/2c015125 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2c015125 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2c015125 Branch: refs/heads/master Commit: 2c0151256aa10bc8434444674a6bc3b17414cdc4 Parents: cfd8ad0 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:42:14 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/2c015125/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