title: Python catching error in a superclass, and track it inside the child class
body: <p>I have been really bothered by something about error handling recently, and I have not successding in finding an answer on the internet :</p>
  
  <p>Basically, I have most of my classes that are all descending from a superclass that handles different things.</p>
  
  <p>I would like to do the error handling only once, in this superclass. The problem is : I don't know how to track the error to the child class !
  The most detailed tracking tools I have found on the internet so far are :</p>
  
  <pre><code>exc_type, exc_obj,  tb = sys.exc_info()
  f = tb.tb_frame
  lineno = tb.tb_lineno
  filename = f.f_code.co_filename
  linecache.checkcache(filename)
  line = linecache.getline(filename, lineno, f.f_globals)
  err_msg = 'Exception in ({}, line {} "{}"): {}'.format(filename, lineno, line.strip(), exc_obj)
  
  traceback.print_stack()
  </code></pre>
  
  <p>But basically, it leads me only the the line of the superclass where I try to display it, so I don't know where it comes from and I end up using prints everywhere to track my error :/</p>
  
  <p>so basically :</p>
  
  <p>~==~ superclass ~==~</p>
  
  <pre><code>1 class MySuperClass(-stuff-):
  2    class Meta:
  3       abstract = True
  4    -stuff-
  5 
  6    def myMethod(-stuff-):
  7       try:
  8          context = self.myChildMethod(-stuff-)
  9       except Exception as e:
  10         -display the error from e, and log it-
  </code></pre>
  
  <p>~==~ My child class ~==~</p>
  
  <pre><code>1 class ChildClass(MySuperClass):
  2    def myChildMethod:
  3       -stuff1-
  4       -stuff2-
  5       -stuff3-
  6       return -somestuff-
  </code></pre>
  
  <p>For example, if my error comes from the -stuff2-, I would like to have the information that it comes from the file containing the "ChildClass", at the line 4.</p>
  
  <p>BUT, what I am getting at most ends up being the file of the superclass, at line 8.</p>
  
  <p>the print_stack() looks like this basically :</p>
  
  <pre><code>lots of lines of the API I don't understand like base.py line 90570930 in blablabla
  File -blablabla- super_view.py, line 8, in myMethod
     traceback.print_stack()
  </code></pre>
  
  <p>So is there a way to climb back to the child class, where the error actually comes from ?</p>
  
  <p>I believe that there should be one but ... I've been searching for a little while, and I am still stuck with this, so if any python expert ( or well experienced with it ^^ ) know this ....</p>