Hi Stephen
You are welcome! Please see my response below.
On 5/3/22 2:33 AM, Stephen Sacks wrote:
Hi Asim,
Thanks for your help. But I have no experience with raising an
exception, so I need more help. I ran the following 7 lines of code
in the Python console in Qgis:
fName = 'xyz'
vrbl = False
class MyExcpt:
pass
if not vrbl:
raise MyExcpt("Unable to find file %s" % fName)
I got the following error: TypeError: MyExcpt() takes no arguments
Indeed, my bad, I wrote an incorrect code snippet. The correct way is
define the exception class as follows:
class MyException(Exception):
pass
User defined exception classes should be derived from the built-in
Exception class. Note that exceptions raised from QGIS Python console
are not reported in the QGIS messages tab.
Asim
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user