From 44067dfff96d77608dc2b994eac802e5e1e5affe Mon Sep 17 00:00:00 2001 From: Srinivasan Sekar Date: Thu, 5 Jul 2018 01:18:26 +0530 Subject: [PATCH 1/3] better handling of invocationtargetexception --- .../appium/java_client/remote/AppiumCommandExecutor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java index 0acc215f8..6853fdd81 100644 --- a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java +++ b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java @@ -191,13 +191,18 @@ public Result createSession(HttpClient client, Command command) return toReturn; }).orElseThrow(() -> new SessionNotCreatedException( format("Unable to create new remote session. desired capabilities = %s", desired))); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + } catch (NoSuchMethodException | IllegalAccessException e) { throw new WebDriverException(format("It is impossible to create a new session " + "because 'createSession' which takes %s, %s and %s was not found " + "or it is not accessible", HttpClient.class.getSimpleName(), InputStream.class.getSimpleName(), long.class.getSimpleName()), e); + } catch (InvocationTargetException e) { + Throwable cause = e.getCause(); + throw new SessionNotCreatedException( + format("Unable to create new remote session. desired capabilities = %s" + + "and reason is " + cause.getMessage(), desired)); } } finally { os.reset(); From adba94df10a76fe45ab74a333d53a24bea1020bf Mon Sep 17 00:00:00 2001 From: Srinivasan Sekar Date: Thu, 5 Jul 2018 14:08:58 +0530 Subject: [PATCH 2/3] address review comments --- .../io/appium/java_client/remote/AppiumCommandExecutor.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java index 6853fdd81..a376a2e66 100644 --- a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java +++ b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java @@ -199,10 +199,8 @@ public Result createSession(HttpClient client, Command command) InputStream.class.getSimpleName(), long.class.getSimpleName()), e); } catch (InvocationTargetException e) { - Throwable cause = e.getCause(); throw new SessionNotCreatedException( - format("Unable to create new remote session. desired capabilities = %s" - + "and reason is " + cause.getMessage(), desired)); + format("Unable to create new remote session. desired capabilities = %s", desired), e); } } finally { os.reset(); From 7ba51ad2952d513288ee4471eb7632a4f15a669d Mon Sep 17 00:00:00 2001 From: Srinivasan Sekar Date: Thu, 5 Jul 2018 15:14:00 +0530 Subject: [PATCH 3/3] address review comments --- .../io/appium/java_client/remote/AppiumCommandExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java index a376a2e66..5e3184f14 100644 --- a/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java +++ b/src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java @@ -200,7 +200,7 @@ public Result createSession(HttpClient client, Command command) long.class.getSimpleName()), e); } catch (InvocationTargetException e) { throw new SessionNotCreatedException( - format("Unable to create new remote session. desired capabilities = %s", desired), e); + format("Unable to create new remote session. Desired capabilities: %s", desired), e); } } finally { os.reset();