def reraise_as(new_exception_or_type):
 __traceback_hide__ = True
 (e_type, e_value, e_traceback) = sys.exc_info()
 if inspect.isclass(new_exception_or_type):
  new_type = new_exception_or_type
  new_exception = new_exception_or_type()
 else:
  new_type = type(new_exception_or_type)
  new_exception = new_exception_or_type
 new_exception.__cause__ = e_value
 try:
  six.reraise(new_type, new_exception, e_traceback)
 finally:
  del e_traceback

def reraise_as ( new_exception_or_type ) : __traceback_hide__ = True ( e_type , e_value , e_traceback ) = sys . exc_info ( ) if inspect . isclass ( new_exception_or_type ) : new_type = new_exception_or_type new_exception = new_exception_or_type ( ) else : new_type = type ( new_exception_or_type ) new_exception = new_exception_or_type new_exception . __cause__ = e_value try : six . reraise ( new_type , new_exception , e_traceback ) finally : del e_traceback
obtained from URL .