From 9c6438015b0808e2ed200afa382e78d53a356a98 Mon Sep 17 00:00:00 2001 From: Tobias Leich Date: Sun, 27 Mar 2016 20:19:27 +0200 Subject: [PATCH] fix handling of failed requests --- lib/Selenium/WebDriver/Wire.pm6 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Selenium/WebDriver/Wire.pm6 b/lib/Selenium/WebDriver/Wire.pm6 index 7870a95..a17fadb 100644 --- a/lib/Selenium/WebDriver/Wire.pm6 +++ b/lib/Selenium/WebDriver/Wire.pm6 @@ -721,13 +721,14 @@ method _die(Str $method, Str $command, $response) { say "Died while doing '$method $command', content:\n"; say $response.content if $response.defined; say "end of content\n"; + return unless $response.defined; my $o = from-json($response.content); my $error = $o; Selenium::WebDriver::X::Error.new( - reason => $error, + reason => $error // '', screenshot => $error, - class => $error + class => $error // '' ).throw; } =begin markdown @@ -773,7 +774,7 @@ method _execute-command(Str $method, Str $command, Hash $params = {}) { $result = from-json( $response.content ); } else { - self._die($method, $command, $_); + self._die($method, $command, $response); warn "FAILED: " ~ $response.status-line if self.debug; }