@contextmanager
def augment_usage_errors(ctx, param=None):
 try:
  (yield)
 except BadParameter as e:
  if (e.ctx is None):
   e.ctx = ctx
  if ((param is not None) and (e.param is None)):
   e.param = param
  raise
 except UsageError as e:
  if (e.ctx is None):
   e.ctx = ctx
  raise

@ contextmanager def augment_usage_errors ( ctx , param = None ) : try : ( yield ) except BadParameter as e : if ( e . ctx is None ) : e . ctx = ctx if ( ( param is not None ) and ( e . param is None ) ) : e . param = param raise except UsageError as e : if ( e . ctx is None ) : e . ctx = ctx raise
context manager that attaches extra information to exceptions that fly .