INNER CODE UNIT · Python
MicronautJavaException
micronaut-projects/micronaut-core · context-python/src/main/resources/META-INF/GRAALPY-VFS/micronaut-application/src/micronaut_asyncio.py:123
class MicronautJavaException(RuntimeError):
"""Python exception carrying a Java ``Throwable`` that failed an awaited Java value.
GraalPy cannot attach a traceback to a foreign exception, which is what
``asyncio.Future.result`` does when a stored exception is re-raised. Java
failures are therefore stored behind this Python exception. The bridge
unwraps ``java_exception`` when the failure crosses back into Java, so the
original Java exception type is preserved end to end. It is a ``RuntimeError``
so Python code that handled the previous ``RuntimeError(str(throwable))``
keeps working; the Java exception is available as ``java_exception``.
"""
def __init__(self, java_exception):
super().__init__(str(java_exception))
self.java_exception = java_exception
_AsyncioRuntime = java.type("io.micronaut.context.python.PythonAsyncioRuntime")