#NEWLINE# def err_exit( message = '' , code = None , expected_exceptions = default_expected_exceptions , arg_parser = None , ignore_sigpipe = True , exception = None ) : #NEWLINE# #INDENT# 'Exits the program, printing information about the last exception (if\n    any) and an optional error message.  Uses *exception* instead if provided.\n\n    Uses **expected_exceptions** to set the error code decide whether to\n    suppress the error traceback.\n\n    :param message: Message to be printed after the exception information.\n    :type message: string\n    :param code: Exit code.\n    :type code: integer (valid exit code, 0-255)\n    :param expected_exceptions: Exceptions for which to exit with error code 3 (expected error condition) and suppress the stack trace (unless the _DX_DEBUG environment variable is set).\n    :type expected_exceptions: iterable\n    :param arg_parser: argparse.ArgumentParser object used in the program (optional)\n    :param ignore_sigpipe: Whether to exit silently with code 3 when IOError with code EPIPE is raised. Default true.\n    :type ignore_sigpipe: boolean\n    :param exception: an exception to use in place of the last exception raised\n    ' #NEWLINE# if ( arg_parser is not None ) : #NEWLINE# #INDENT# message = ( ( arg_parser . prog + ': ' ) + message ) #NEWLINE# #UNINDENT# exc = ( exception if ( exception is not None ) else sys . exc_info ( ) [ 1 ] ) #NEWLINE# if isinstance ( exc , SystemExit ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( exc , expected_exceptions ) : #NEWLINE# #INDENT# exit_with_exc_info ( EXPECTED_ERR_EXIT_STATUS , message , print_tb = ( dxpy . _DEBUG > 0 ) , exception = exception ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ignore_sigpipe and isinstance ( exc , IOError ) and ( getattr ( exc , 'errno' , None ) == errno . EPIPE ) ) : #NEWLINE# #INDENT# if ( dxpy . _DEBUG > 0 ) : #NEWLINE# #INDENT# print ( 'Broken pipe' , file = sys . stderr ) #NEWLINE# #UNINDENT# sys . exit ( 3 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( exception is None ) : #NEWLINE# #INDENT# code = 1 #NEWLINE# #UNINDENT# exit_with_exc_info ( code , message , print_tb = True , exception = exception )