[Qgis-user] quit() and exit()
Asim
asimrp at lavabit.com
Tue May 3 02:42:32 PDT 2022
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220503/f250be12/attachment.htm>
More information about the Qgis-user
mailing list