title: How to set a standard exception handler for multiple functions
body: <p>Let's say I have three functions that do different things but should react to a set of exceptions in the same way. One of them might look like:</p>
  
  <pre><code>def get_order_stat(self, Order_id):
      status_returned = False
      error_count = 0
      while status_returned == False:
          try:
              stat_get = client.queryOrder(orderId=Order_id)
          except MalformedRequest:
              print('Order ID not yet findable, keep trying')
              error_count += 1
              time.sleep(int(1))
          except InternalError:
              print('Order check returned InternalError, keep trying')
              error_count += 1
              time.sleep(int(1))
          except StatusUnknown:
              print('Order check returned StatusUnknown, keep trying')
              error_count += 1
              time.sleep(int(1))
          else:
              status = stat_get['status']
              status_returned = True
          finally:
              if error_count &gt;= 10:
                  print('Error loop, give up')
                  break
      return status
  </code></pre>
  
  <p>The vast majority of the code is the exception handling, and I'd like to avoid having to repeat it in every function that needs it. Is there a way to define something like an exception handling function containing the handling code? Ideally my function would end up effectively:</p>
  
  <pre><code>def get_order_stat(self, Order_id):
      status_returned = False
      while status_returned == False:
          try:
              stat_get = client.queryOrder(orderId=Order_id)
          except:
              handler_function()
          else:
              status = stat_get['status']
              status_returned = True
      return status
  </code></pre>