def squelch_exceptions(fn):
 @functools.wraps(fn)
 def squelched_fn(*a, **kw):
  try:
   return fn(*a, **kw)
  except BaseException:
   if g.debug:
    raise
   else:
    g.log.exception('squelching exception')
 return squelched_fn

def squelch_exceptions ( fn ) : @ functools . wraps ( fn ) def squelched_fn ( * a , ** kw ) : try : return fn ( * a , ** kw ) except BaseException : if g . debug : raise else : g . log . exception ( 'squelching exception' ) return squelched_fn
wrap a function to log and suppress all internal exceptions when running in debug mode .