-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
JS Exception Support #102
JS Exception Support #102
Conversation
Time Change: +75.5ms (0%) Total Time: 10,698ms
ℹ️ View Unchanged
|
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.
LGTM, awesome work!
Runtime/src/index.ts
Outdated
let result: any | ||
try { | ||
result = Reflect.construct(obj, decodeValues(argv, argc)); | ||
if (typeof result != "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.
I’m pretty sure new
can’t return a non-object. If you try to return a non-object in a constructor, it will use the this
value instead.
See the spec here, where step 12 is the most relevant.
@j-f1 @MaxDesiatov What do you think about this API? I think there may be better interface. |
If there's a better API for it, I can't come up with it... |
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.
LGTM! We’re not at 1.0 yet so we can continue to iterate if necessary.
Currently, there is no way to catch exceptions thrown by JavaScript functions using JavaScriptKit.
This PR introduces new two APIs to catch exceptions.
JSFunction.throws
JSObject.throwing
JSFunction.throws
convertsJSFunction
into throwable function.JSObject.throwing
provides throwing method call API capturingthis
context.These two APIs have different names to avoid overload ambiguity.
e.g.