Browse Source
The `reason` in a rejected promise should be an instance of `Error`. That leads to better error messages on the JavaScript side. Signed-off-by: Damien George <damien@micropython.org>pull/14434/head
Damien George
6 months ago
3 changed files with 25 additions and 2 deletions
@ -0,0 +1,11 @@ |
|||
// Test raising an exception in async Python code running in runPythonAsync,
|
|||
// that the JavaScript-level promise is rejected with a PythonError.
|
|||
|
|||
const mp = await (await import(process.argv[2])).loadMicroPython(); |
|||
|
|||
try { |
|||
await mp.runPythonAsync("await fail"); |
|||
} catch (error) { |
|||
console.log(error.name, error.type); |
|||
console.log(error.message); |
|||
} |
@ -0,0 +1,5 @@ |
|||
PythonError NameError |
|||
Traceback (most recent call last): |
|||
File "<stdin>", line 1, in <module> |
|||
NameError: name 'fail' isn't defined |
|||
|
Loading…
Reference in new issue