-
Notifications
You must be signed in to change notification settings - Fork 0
added error handling via MaybeLocal #40
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
Conversation
|
|
||
| Local<Value> result = script.ToLocalChecked()->Run(); | ||
| if (result.IsEmpty()) { | ||
| ReportException(env, try_catch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did the try_catch do? If it's not needed any longer, remove it from line 5259.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest with you, i dont know exactly what the TryCatch does. However, it is also used in line 5267 (if (script.IsEmpty())). Therefore, i would not remove it entirely (at least not until we figured out more about it).
| exit(4); //TODO jh: don't exit process when function breaks. Handle error differently. | ||
| } | ||
|
|
||
| return scope.Escape(result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did this do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scope.Escape(...) pushes the given handle into the previously active scope.
This is used in order to save the result, once the script returned (since the scripts scope should be closed after it was executed).
It seems that this is needed for our usecase as well, therefore i will put it back in the code within my next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (see b023788)
|
|
||
| if (!maybe_arg.ToLocal(&arg)) { | ||
| // cannot create v8 string | ||
| return MaybeLocal<v8::Object>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we return maybe_arg here? Couldn't it carry valuable information for the application programmer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally, why do we always return a new MaybeLocal object and not the one that failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe_arg is of type MaybeLocal<v8::String> while the method returns MaybeLocal<v8::Object>. Casting one MaybeLocal<T> to another MaybeLocal<V> is only possible when casting to a Local<T> and then to Local<V>, which then can be wrapped inside a MaybeLocal<V>.
Long story short: Its not the way we want the code to look like. trust me
cmfcmf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Nicely done. I've only got one more minor thing (see above).
Do you mind opening an issue to investigate what try_catch does? It might not only apply to the particular function but could also potentially be used in our other functions as well.
Nevermind, looks all good 👍 |
|
We just fixed the apps to actually work with these changes, shame on the approvers of this PR!! 😉 |
No description provided.