Skip to content
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

Handle errors from python session #26

Open
michaelwooley opened this issue Apr 26, 2022 · 1 comment
Open

Handle errors from python session #26

michaelwooley opened this issue Apr 26, 2022 · 1 comment
Labels
python Python repl/emulator from wasm

Comments

@michaelwooley
Copy link
Owner

No description provided.

@michaelwooley michaelwooley added the python Python repl/emulator from wasm label Apr 26, 2022
@michaelwooley
Copy link
Owner Author

Here is a sample error:

{
    "exc_type": "TypeError",
    "traceback": [
        {
            "name": "<module>",
            "lineno": 4,
            "filename": "<wasm>"
        },
        {
            "name": "f",
            "lineno": 2,
            "filename": "<wasm>"
        }
    ],
    "suppress_context": false,
    "args": [
        "'+' not supported between instances of 'int' and 'NoneType'"
    ],
    "rendered": "Traceback (most recent call last):\n  File \"<wasm>\", line 4, in <module>\n  File \"<wasm>\", line 2, in f\nTypeError: '+' not supported between instances of 'int' and 'NoneType'\n"
}

Catch via:

		try {
			pyExec(code, {
				stdout: (out: string): void => {
					// console.log(`Got stdout: ${out} (JSON/escaped: ${JSON.stringify(out)})`);

					s = s + out;
				}
			});
		} catch (err) {
			console.log(Object.keys(err));
			console.log(err.info);
			console.error(err);
		}

All of the above is in err.info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Python repl/emulator from wasm
Projects
None yet
Development

No branches or pull requests

1 participant