Skip to content

Commit

Permalink
Try harder to get a meaningful error message
Browse files Browse the repository at this point in the history
  • Loading branch information
JRaspass committed Jan 2, 2018
1 parent c8e0871 commit 7988cc2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.101 2018-01-02
- Try harder to get a meaningful error message.

0.100 2017-12-21
- This is a breaking chance, we now support the latest WebDriver spec and
test on the latest geckodriver, I suspect phantomjs no longer works, but
Expand Down
9 changes: 7 additions & 2 deletions lib/WebDriver/Tiny.pm
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,13 @@ sub _req {

my $value = eval { JSON::PP::decode_json( $reply->{content} )->{value} };

Carp::croak ref $self, ' - ', $value ? $value->{message} : $reply->{content}
unless $reply->{success};
unless ( $reply->{success} ) {
my $error = $value
? $value->{message} || $value->{error} || $reply->{content}
: $reply->{content};

Carp::croak ref $self, ' - ', $error;
}

$value;
}
Expand Down

0 comments on commit 7988cc2

Please sign in to comment.