(name='Error')
Displays an exception to the user, optionally displaying a full traceback
    and spawning an interactive post-moretem debugger.

    Notes:
        - ``set exception-verbose on`` enables stack traces.
        - ``set exception-debugger on`` enables the post-mortem debugger.
Displays an exception to the user, optionally displaying a full traceback
    and spawning an interactive post-moretem debugger.
Displays an exception to the user optionally displaying a full traceback and spawning an interactive post - moretem debugger .
def handle(name='Error'):
    """Displays an exception to the user, optionally displaying a full traceback
    and spawning an interactive post-moretem debugger.

    Notes:
        - ``set exception-verbose on`` enables stack traces.
        - ``set exception-debugger on`` enables the post-mortem debugger.
    """

    # This is for unit tests so they fail on exceptions instead of displaying them.
    if getattr(sys, '_pwndbg_unittest_run', False) is True:
        E, V, T = sys.exc_info()
        e = E(V)
        e.__traceback__ = T
        raise e

    # Display the error
    if debug or verbose:
        exception_msg = traceback.format_exc()
        print(exception_msg)
        inform_report_issue(exception_msg)

    else:
        exc_type, exc_value, exc_traceback = sys.exc_info()

        print(message.error('Exception occurred: {}: {} ({})'.format(name, exc_value, exc_type)))

        print(message.notice('For more info invoke `') +
              message.hint('set exception-verbose on') +
              message.notice('` and rerun the command\nor debug it by yourself with `') +
              message.hint('set exception-debugger on') +
              message.notice('`'))

    # Break into the interactive debugger
    if debug:
        with pwndbg.stdio.stdio:
            pdb.post_mortem()
def handle ( name = 'Error' ) : # This is for unit tests so they fail on exceptions instead of displaying them. if getattr ( sys , '_pwndbg_unittest_run' , False ) is True : E , V , T = sys . exc_info ( ) e = E ( V ) e . __traceback__ = T raise e # Display the error if debug or verbose : exception_msg = traceback . format_exc ( ) print ( exception_msg ) inform_report_issue ( exception_msg ) else : exc_type , exc_value , exc_traceback = sys . exc_info ( ) print ( message . error ( 'Exception occurred: {}: {} ({})' . format ( name , exc_value , exc_type ) ) ) print ( message . notice ( 'For more info invoke `' ) + message . hint ( 'set exception-verbose on' ) + message . notice ( '` and rerun the command\nor debug it by yourself with `' ) + message . hint ( 'set exception-debugger on' ) + message . notice ( '`' ) ) # Break into the interactive debugger if debug : with pwndbg . stdio . stdio : pdb . post_mortem ( )