Skip to content

Commit 40e8299

Browse files
authored
Merge pull request #92 from odlp/timeout-error-output
Include process output in ProcessTimeoutError
2 parents 6bb4133 + 02234d5 commit 40e8299

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

lib/ferrum.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def message
3737
end
3838

3939
class ProcessTimeoutError < Error
40-
def initialize(timeout)
40+
attr_reader :output
41+
42+
def initialize(timeout, output)
43+
@output = output
4144
super("Browser did not produce websocket url within #{timeout} seconds")
4245
end
4346
end

lib/ferrum/browser/process.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def parse_ws_url(read_io, timeout)
145145

146146
unless ws_url
147147
@logger.puts(output) if @logger
148-
raise ProcessTimeoutError.new(timeout)
148+
raise ProcessTimeoutError.new(timeout, output)
149149
end
150150
end
151151

spec/browser_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ module Ferrum
6464
)
6565
end
6666

67+
it "includes the process output in the error" do
68+
path = "#{PROJECT_ROOT}/spec/support/broken_chrome"
69+
70+
expect {
71+
Browser.new(browser_path: path)
72+
}.to raise_error(Ferrum::ProcessTimeoutError) do |ex|
73+
expect(ex.output).to include "Broken Chrome error message"
74+
end
75+
end
76+
6777
it "raises an error and restarts the client if the client dies while executing a command" do
6878
expect { browser.crash }.to raise_error(Ferrum::DeadBrowserError)
6979
browser.go_to

spec/support/broken_chrome

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
echo "Broken Chrome error message"
4+
echo "$0"
5+
exit 1

0 commit comments

Comments
 (0)