Repository navigation
fix(runtime): raise JavaScriptError for any thrown value, not only Error instances - #675
Merged
Merged
Conversation
…ror instances handle_error looked at the result's subtype instead of exceptionDetails, so throwing a string or an object returned it as the result, while returning an Error object crashed with NoMethodError. JavaScriptError's message includes the thrown primitive, e.g. "Uncaught smth" instead of just "Uncaught".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
handle_errorchecked the result'ssubtypeinstead ofexceptionDetails, so:throw "smth",throw { code: 1 }or a promise rejected with a non-Error value were returned as the result ofevaluate,execute,evaluate_asyncandevaluate_oninstead of raisingErrorobject crashed withNoMethodError, becauseJavaScriptErrorwas built from missingexceptionDetailsNow any
exceptionDetailsraisesJavaScriptError(orScriptTimeoutErrorfor the async timeout), and a returnedErroris converted like any other object. For a thrown primitive the message includes the value, e.g.Uncaught smthinstead ofUncaught; thrownErrors keep the sameclass_name,messageandstack_trace.The existing
evaluate(%(throw "smth"))spec only passed because thereturnwrapper made it a syntax error; the new specs throw for real and fail without the fix.Cuprite's custom JS errors all extend
Error, so its behavior doesn't change:session_spec.rbanddriver_spec.rbpass against this branch.