How to handle returned exception error object by Embedded Python method?
How can I get the Python error object(exception return value) from the embedded python method?
I have an embedded Python method like as below;
ClassMethod test2() As XXX [ Language = python ]
{
try:
a=1/0
except Exception as ex:
print("Exception: %s" % str(ex))
return ex
}
I'm not sure what kind of return type to set for this classmethod. "As XXX" <--
I tried to set "ClassMethod test2() As %Exception.PythonException [ Language = python ]"
However, I got the following return value when I run the method in the IRIS terminal.
USER>set st= ##class(User.PythonTest).test2()
Exception: division by zero
USER>zw st
st=4@%SYS.Python ; division by zero ; <OREF>
USER>
How can I return the python error object(ex)?
Please let me know if you know a good way to raise or return errors in the Embedded Python method.
Product version: IRIS 2021.2
$ZV: IRIS for Windows (x86-64) 2021.2 (Build 651U) Mon Jan 31 2022 17:39:05 EST