Skip to content

Commit 119a6d5

Browse files
committed
Rescue exception while saving artifacts
1 parent 48eab7d commit 119a6d5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/spec_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,22 @@ def save_exception_aftifacts(browser, meta)
6666
line_number = meta[:line_number]
6767
timestamp = "#{time_now.strftime("%Y-%m-%d-%H-%M-%S.")}#{"%03d" % (time_now.usec/1000).to_i}"
6868

69+
save_exception_log(filename, line_number, timestamp)
70+
save_exception_screenshot(filename, line_number, timestamp)
71+
end
72+
73+
def save_exception_screenshot(filename, line_number, timestamp)
6974
screenshot_name = "screenshot-#{filename}-#{line_number}-#{timestamp}.png"
7075
screenshot_path = "/tmp/ferrum/#{screenshot_name}"
7176
browser.screenshot(path: screenshot_path, full: true)
77+
rescue => e
78+
puts "#{e.class}: #{e.message}"
79+
end
7280

81+
def save_exception_log(filename, line_number, timestamp)
7382
log_name = "logfile-#{filename}-#{line_number}-#{timestamp}.txt"
7483
File.open("/tmp/ferrum/#{log_name}", "wb") { |file| file.write(FERRUM_LOGGER.string) }
84+
rescue => e
85+
puts "#{e.class}: #{e.message}"
7586
end
7687
end

0 commit comments

Comments
 (0)