solana-playground
solana-playground copied to clipboard
Non-awaited async function errors don't get caught
Problem
The following client code gets caught:
function throwError() {
throw new Error("Failure!");
}
throwError();
async function throwError() {
throw new Error("Failure!");
}
await throwError();
and prints to terminal correctly:
$ run
Running client...
client.ts:
Uncaught error: Failure!
but the error doesn't get caught if it's an async function without an await call:
async function throwError() {
throw new Error("Failure!");
}
throwError();
Solution
Catch the error from the iframe and print it in the terminal similar to how the other errors are handled.