Capture Stack Trace Decorator

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import traceback

def catch(func):
    """
    Catches any exception and prints a stack trace.
    """
    def wrapper(*args,**kwargs):
        try:
            return func(*args,**kwargs)
        except:
            traceback.print_exc()
    
    return wrapper

More like this

  1. function tracing decorator by amitu 4 years, 3 months ago
  2. Print Exceptions to the Console by ericflo 3 years, 10 months ago
  3. Other approach of making middleware (by decorators) by diverman 2 years, 3 months ago
  4. Accessing Environment Variables in Views by LorenDavie 4 years, 10 months ago
  5. Accessing Environment Variables in Templates by LorenDavie 4 years, 10 months ago

Comments

(Forgotten your password?)