-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[rb] Add backtrace locations and cause to errors #14170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3ff3559
eb6aa00
ec6f5bc
6540f73
777a8a6
6883b0a
6a76481
0447c6d
4aae5a3
7e4a2cf
3c7b386
c4e2593
de16eec
4afe312
33bd311
48cb412
10791b2
5139bbf
d798475
2996653
05cfce6
ada5081
7529157
3c64035
5c9808a
176286c
48a7105
ef832d5
1f1dcae
c36c565
7497293
2f8b9f7
a506504
c7bc5d2
32536f5
eb0248e
9ff8252
ea9f4b4
ac8e22a
bfedee9
834a678
0ef5372
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ class Response | |
attr_reader :code, :payload | ||
|
||
def initialize(code, payload = nil) | ||
@code = code | ||
@code = code | ||
@payload = payload || {} | ||
|
||
assert_ok | ||
|
@@ -37,11 +37,8 @@ def initialize(code, payload = nil) | |
def error | ||
error, message, backtrace = process_error | ||
klass = Error.for_error(error) || return | ||
|
||
ex = klass.new(message) | ||
ex.set_backtrace(caller) | ||
add_backtrace ex, backtrace | ||
|
||
add_cause(ex, error, backtrace) | ||
ex | ||
end | ||
|
||
|
@@ -59,34 +56,12 @@ def assert_ok | |
raise Error::ServerError, self | ||
end | ||
|
||
def add_backtrace(ex, server_trace) | ||
aguspe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return unless server_trace | ||
|
||
backtrace = case server_trace | ||
when Array | ||
backtrace_from_remote(server_trace) | ||
when String | ||
server_trace.split("\n") | ||
end | ||
|
||
ex.set_backtrace(backtrace + ex.backtrace) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably the only line that should have been changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed during testing that when setting the backtrace to the exception a couple of things happened:
Let me know if this doesn't make much sense to you and I will gladly make a PR to update this :) thank you so much for the help! |
||
end | ||
|
||
def backtrace_from_remote(server_trace) | ||
aguspe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
server_trace.filter_map do |frame| | ||
next unless frame.is_a?(Hash) | ||
|
||
file = frame['fileName'] | ||
line = frame['lineNumber'] | ||
meth = frame['methodName'] | ||
|
||
class_name = frame['className'] | ||
file = "#{class_name}(#{file})" if class_name | ||
|
||
meth = 'unknown' if meth.nil? || meth.empty? | ||
|
||
"[remote server] #{file}:#{line}:in `#{meth}'" | ||
end | ||
def add_cause(ex, error, backtrace) | ||
cause = Error::WebDriverError.new | ||
cause.set_backtrace(backtrace) | ||
raise ex, cause: cause | ||
rescue Error.for_error(error) | ||
ex | ||
end | ||
|
||
def process_error | ||
|
Uh oh!
There was an error while loading. Please reload this page.