Manu,
I am wondering why you would expect anything when you raise an exception without defining what you raised, in the first example.
The 2nd code segment would raise the exceptions and pass @PYEXCEPTIONTYPE , @PYEXCEPTIONMSG, and @PYEXCEPTIONTRACEBACK
forum.py
-----
def myfnc(a):
if a < 2:
raise ValueError(f"integer above 1 expected, got {a}")
return a
------
TEST
----
ModuleName = "forum"
FuncName = "myfnc"
* call the Python function
CRT "Enter data ":;INPUT stuff
IF NUM(stuff) THEN stuff += 0
pyresults = PyCallFunction(ModuleName, FuncName, stuff)
IF @PYEXCEPTIONTYPE = '' THEN
CRT "OUTPUT = " :pyresults
END ELSE
CRT " EXCEPTION TYPE:" :@PYEXCEPTIONTYPE
CRT " EXCEPTION MESSAGE:" :@PYEXCEPTIONMSG
CRT "EXCEPTIONTRACEBACK:" :@PYEXCEPTIONTRACEBACK
END
END
-----
Then when I run, I get:
>RUN PBP TEST
Enter data ?0
EXCEPTION TYPE:ValueError
EXCEPTION MESSAGE:integer above 1 expected, got 0
EXCEPTIONTRACEBACK:Traceback (most recent call last):
File "C:\U2\UV\XDEMO\PP\forum.py", line 4, in myfnc
raise ValueError(f"integer above 1 expected, got {a}")
ValueError: integer above 1 expected, got 0
So, I am not sure why you mentioned you received null?
As for best practice, I would recommend you create your own custom exception, and raise that in your code.
Following is a good site that shows how this can be done:
https://www.programiz.com/python-programming/user-defined-exception#:~:text=In%20Python%2C%20we%20can%20define,pass%20try%3A%20...
Mike