Skip to content

Error Handling

Demonstrates Python error handling with detailed diagnostic information. Every Python exception is wrapped as a PythonExecutionException providing error type, cause code, and full Python traceback.

View source

Key Points

  • PythonExecutionException wraps all Python errors
  • getPythonErrorType()SyntaxError, NameError, ValueError, etc.
  • getCauseCode() — the Python code that caused the error
  • getPythonTraceback() — full Python traceback string
  • Works for both eval() and exec()

Run It

./gradlew :python-embed-examples:error-handling:run