-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Fix Error constructors to return rather than throw #749
Conversation
SyntaxError.toString was using Value::display while all other error types use Value::to_string
Codecov Report
@@ Coverage Diff @@
## master #749 +/- ##
==========================================
+ Coverage 59.13% 59.21% +0.07%
==========================================
Files 155 155
Lines 9838 9857 +19
==========================================
+ Hits 5818 5837 +19
Misses 4020 4020
Continue to review full report at Codecov.
|
Introduces some changes accross files to accommodate for the change Fix: Correct Error.prototype.toString to use Value::to_string rather than Value::Display Test: Add a test case for Error Objects in Object.prototype.toString
This should now be unblocked since #722 has been merged :) |
@HalidOdat on Discord we discussed using There are some places where I'm forced to use |
If we know that it |
Ok, that's my opinion too, there's no need for |
The idea here is that if at any point in our code, we should never ever reach a branch, it's good to panic. Wether that branch is an A panic should mean "we messed up, this is a bug in Boa 100% for sure", and no JavaScript code should ever cause a panic (we still have to solve this part). But in this case, I think |
Co-authored-by: Halid Odat <halidodat@gmail.com>
On
master
let e = new Error('test');
doesn't work and results in an uncaught error, this PR fixes that by making it so the Error constructors aren't seen as throwing their return value byboa
.Originally opened because
SyntaxError.toString
andError.toString
were usingValue::display
while all other error types useValue::to_string
.I don't think this has any effect right now, but I think the errors should all conform to the same pattern.
Has an example you can see
TypeError
's implementation below:boa/boa/src/builtins/error/type.rs
Lines 58 to 63 in e83a03a
It changes the following:
Ok()
rather thanErr()
Change conversion ofname
andmessage
to useValue::to_string
rather thanValue::display
inSyntaxError.toString