Any unhandled exception raised by Python during a bridge call is caught by the worker, serialized with its type, message, and full traceback, and sent back over the JSON-RPC channel. On the JavaScript side, the pendingDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Crane04/esem/llms.txt
Use this file to discover all available pages before exploring further.
Promise is rejected with a PythonError instance — a subclass of the native Error class — giving you structured access to everything Python reported.
The PythonError class
PythonError extends the built-in JavaScript Error. It carries three extra properties in addition to the standard message:
| Property | Type | Description |
|---|---|---|
err.message | string | The Python exception message, e.g. "Input cannot be empty" |
err.name | string | "PythonError(ErrorType)", e.g. "PythonError(ValueError)" |
err.pythonTraceback | string | The full Python traceback as a multi-line string |
err.isPythonError | boolean | Always true — useful for duck-typing without an instanceof check |
Example: catching a Python exception
Define a Python function that raises:PythonError in JavaScript:
Verified by the test suite
The following test fromtest/api.test.js confirms that all three properties are populated correctly when a Python exception crosses the bridge:
PythonError extends native Error
PythonError is a proper subclass of the JavaScript Error class. It works naturally with any standard error-handling pattern: try/catch, Promise .catch(), assert.rejects(), logging libraries, and error-monitoring services. Stack traces and instanceof checks all behave as expected.Narrowing Python errors from JS errors
Worker crash
If the Python worker process exits with a non-zero exit code — due to a segfault, an unhandled top-level exception, or an externalSIGKILL — the bridge cannot send a structured error response. In that case, every Promise that was waiting for a response from the worker is rejected with a plain JavaScript Error:
python() will spawn a fresh worker automatically.