better handling of invocationtargetexception#968
better handling of invocationtargetexception#968SrinivasanTarget merged 3 commits intoappium:masterappium/java-client:masterfrom SrinivasanTarget:exception_handlingCopy head branch name to clipboard
Conversation
| Throwable cause = e.getCause(); | ||
| throw new SessionNotCreatedException( | ||
| format("Unable to create new remote session. desired capabilities = %s" | ||
| + "and reason is " + cause.getMessage(), desired)); |
There was a problem hiding this comment.
why not to use format specifiers for both arguments?
There was a problem hiding this comment.
Also, it might be handy to pass the original exception as cause constructor argument, so it would be easier to debug it.
There was a problem hiding this comment.
Throwable cause = e.getCause();
throw new SessionNotCreatedException(
format("Unable to create new remote session. desired capabilities = %s"
+ "and reason is %s", desired, cause != null ? cause.getMessage() : null,
e.getTargetException()));
@mykola-mokhnach Do you mean it this way?
There was a problem hiding this comment.
almost. It's just instead of setting reason to null if cause is null you set it to the original exception value
There was a problem hiding this comment.
also SessionNotCreatedException has the second constructor where one can provide the cause:
SessionNotCreatedException(String msg, Throwable cause)
There was a problem hiding this comment.
Yeah i used the same constructor above.
| InputStream.class.getSimpleName(), | ||
| long.class.getSimpleName()), e); | ||
| } catch (InvocationTargetException e) { | ||
| Throwable cause = e.getCause(); |
There was a problem hiding this comment.
can it be that getCause returns null?
| 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); |
There was a problem hiding this comment.
desired capabilities = %s -> Desired capabilities: %s
Change list
Better handling of invocationtargetexception thrown during creating session
Thanks @iddol.
Types of changes
What types of changes are you proposing/introducing to Java client?
Put an
xin the boxes that apply@mykola-mokhnach FYI