Skip to content

Conversation

@Johannes-Schneider
Copy link
Collaborator

No description provided.


Local<Value> result = script.ToLocalChecked()->Run();
if (result.IsEmpty()) {
ReportException(env, try_catch);
Copy link
Collaborator

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.

Copy link
Collaborator Author

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did this do?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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>();
Copy link
Collaborator

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?

Copy link
Collaborator

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?

Copy link
Collaborator Author

@Johannes-Schneider Johannes-Schneider Jan 22, 2018

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

Copy link
Collaborator

@cmfcmf cmfcmf left a 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.

@cmfcmf
Copy link
Collaborator

cmfcmf commented Jan 24, 2018

I've only got one more minor thing (see above).

Nevermind, looks all good 👍

@cmfcmf cmfcmf merged commit 200c1a9 into node_lib Jan 29, 2018
@cmfcmf cmfcmf deleted the error_handling branch January 29, 2018 09:20
@msoechting
Copy link
Collaborator

We just fixed the apps to actually work with these changes, shame on the approvers of this PR!! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants