Repository: camel Updated Branches: refs/heads/camel-2.12.x 740021954 -> dd89d6b88 refs/heads/camel-2.13.x f39312fd0 -> 02a8e9cd5
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/02a8e9cd Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/02a8e9cd Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/02a8e9cd Branch: refs/heads/camel-2.13.x Commit: 02a8e9cd5c023a3a0937a0722f298e8a06cc605a Parents: f39312f Author: Willem Jiang <[email protected]> Authored: Fri Jul 25 14:42:14 2014 +0800 Committer: Willem Jiang <[email protected]> Committed: Fri Jul 25 14:56:37 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/02a8e9cd/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
