-
Notifications
You must be signed in to change notification settings - Fork 359
Async functions should be able to throw exceptions #187
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
Comments
The expression > (new Date('foo-bar')).valueOf()
<- NaN Otherwise, I am not sure what you are asking.
try {
new Array(-1);
} catch (e) {
// e is RangeError: Invalid array length
}
|
I have tried to put a catch block around .run. It did not catch the exception. I will be back with some example to run ( on Docker ;-) ) |
Let me repeat myself: the expression |
Now I have a good example: please go to https://netcoreblockly.herokuapp.com/blockly.html There is a link in the bottom of the page named ignatandrei/NETCoreBlockly#7 It will generate some block that call an HTTP backend that throws an 500 error. How can I intercept this error with the Interpreter from blockly.html ? Thanks |
Oh, OK. You are asking about throwing exceptions, from async native functions, rather than catching them. Async functions can throw exceptions, using the following procedure:
Steps 1 and 4 will always be your responsibility, but steps 2 and 3 really ought to be provided by the JS Interpreter itself—for example, via #178. |
If I understand, I will write in my code: let error= myInterpreter.createObject( { err: 'this is my error'}) Where an error to be raised , I call myInterpreter.unwind(Interpreter.Completion.THROW, error, undefined) This is all , right? |
I tried to copy the code from here: var error = myInterpreter.createObject(interpreter.ERROR); but it gives me: : Non object prototype |
Not sure where you're copying from, but it looks like your first line should read either var error = myInterpreter.createObject(myInterpreter.ERROR) or var error = interpreter.createObject(interpreter.ERROR) depending on the name of the variable containing your |
I have copied from 68bb747 And I have put now: var error = myInterpreter.createObject(myInterpreter.ERROR); but it gives the error: Could you please give a hint? |
Not sure what's going on here. The error message comes from I note that you are using |
1 .I do not know for sure if I want acorn_interpreter or interpreter. What are the differences ? Should I use interpreter ?
( and I can replace any js with what you want) |
So, It won't have either my patch in #178 nor the Use the uncompiled versions instead. |
Take both from the root of the site here ? |
Yes.
Yes. |
Now it does not work at all ( not even what it worked before) Do you want to deploy to take a look? |
You can close. There is a mid - hack to solve it :register a function into the interpreter. Do not throw the error, call this global error handler |
I cannot figure how the interpreter is raising errors when something got wrong ( for example , a
new Date('foo-bar')
)
The text was updated successfully, but these errors were encountered: