title: Python : How to stop execution after exception has been caught?
body: <p>I have a class dataset.py that has a bunch of functions and also a logger implemented which looks like:</p>
  
  <pre><code>class dataset:
      def get_data():
          try:
              if(sourcefile != None):
                  if not os.path.isfile(sourceFile):
                      raise FileNotFoundError
          except FileNotFoundError:
              logger.error('File not found!')
      def do_something():
          return
  </code></pre>
  
  <p>I use these classes in the following way:</p>
  
  <pre><code>datasetObj = dataset()
  datasetObj.get_data()
  datasetObj.do_something()
  </code></pre>
  
  <p>Now, even if get_data() raises a FileNotFoundError it is handled in the except block and the program continues to go to do_something().</p>
  
  <p>How do I stop this? If there is a file not found error then execution should stop.
  How do I return my exception to the caller and make my main.py from executing any further?</p>