You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/10/19 07:17:15 UTC
[camel] 02/09: (chores) camel-support: use standard check for exception type in catch blocks
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 90f33d5a51aa3150a94129d9885aef9e540234d9
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Tue Oct 18 16:42:54 2022 +0200
(chores) camel-support: use standard check for exception type in catch blocks
---
.../org/apache/camel/support/component/ApiMethodHelper.java | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java
index a019b2ceb8a..56a829d08a9 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/component/ApiMethodHelper.java
@@ -521,12 +521,15 @@ public final class ApiMethodHelper<T extends Enum<T> & ApiMethod> {
try {
return method.getMethod().invoke(proxy, values);
+ } catch (InvocationTargetException e) {
+ final Throwable cause = e.getCause();
+
+ String message = cause != null ? cause.getMessage() : e.getMessage();
+
+ throw new RuntimeCamelException(
+ String.format("Error invoking %s with %s: %s", method.getName(), properties, message),
+ cause != null ? cause : e);
} 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);
}