You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2014/06/18 07:50:53 UTC
[3/6] git commit: Fixed ApiMethodHelper to throw
RuntimeCamelException with API exception on InvocationTargetException
Fixed ApiMethodHelper to throw RuntimeCamelException with API exception on InvocationTargetException
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/5dd9cc0f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/5dd9cc0f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/5dd9cc0f
Branch: refs/heads/master
Commit: 5dd9cc0f0981603ea1ac8f0f6ee6dfcb7ad56a26
Parents: dee15fb
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Mon Jun 16 21:21:57 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Tue Jun 17 13:51:39 2014 -0700
----------------------------------------------------------------------
.../java/org/apache/camel/util/component/ApiMethodHelper.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/5dd9cc0f/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
index 2561adc..7ce841b 100644
--- a/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/component/ApiMethodHelper.java
@@ -17,6 +17,7 @@
package org.apache.camel.util.component;
import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -375,6 +376,11 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
try {
return method.getMethod().invoke(proxy, values);
} catch (Throwable e) {
+ if (e instanceof InvocationTargetException) {
+ // get API exception
+ final Throwable cause = e.getCause();
+ e = (cause != null) ? cause : e;
+ }
throw new RuntimeCamelException(
String.format("Error invoking %s with %s: %s", method.getName(), properties, e.getMessage()), e);
}