<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">Hi Stephen</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">You are welcome!  Please see my
      response below.</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">On 5/3/22 2:33 AM, Stephen Sacks wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:446ccf48-91b0-80f2-4e81-2fa841ebc9fc@gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <font size="4">Hi Asim,<br>
           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:<br>
        <br>
        fName = 'xyz'<br>
        vrbl = False<br>
        class MyExcpt:<br>
            pass<br>
        <br>
        if not vrbl:<br>
            raise MyExcpt("Unable to find file %s" % fName)<br>
        <br>
        <br>
        I got the following error:   </font><font size="4">TypeError:
        MyExcpt() takes no arguments</font><br>
    </blockquote>
    <br>
    <p><font size="4">Indeed, my bad, I wrote an incorrect code
        snippet.  The correct way is define the exception class as
        follows:<br>
      </font></p>
    <p><font size="4">    class MyException(Exception):<br>
                pass<br>
      </font></p>
    <p>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.</p>
    <p>Asim<br>
    </p>
  </body>
</html>