@@ -1134,27 +1134,22 @@ def _main(unittest_bz_instance):
11341134
11351135def main (unittest_bz_instance = None ):
11361136 try :
1137- return _main ( unittest_bz_instance )
1138- except KeyboardInterrupt :
1139- log . debug ( "" , exc_info = True )
1140- print ( " \n Exited at user request." )
1141- sys . exit ( 1 )
1137+ try :
1138+ return _main ( unittest_bz_instance )
1139+ except ( Exception , KeyboardInterrupt ):
1140+ log . debug ( "" , exc_info = True )
1141+ raise
11421142 except (Fault , bugzilla .BugzillaError ) as e :
1143- log .debug ("" , exc_info = True )
11441143 print ("\n Server error: %s" % str (e ))
11451144 sys .exit (3 )
11461145 except ProtocolError as e :
1147- log .debug ("" , exc_info = True )
11481146 print ("\n Invalid server response: %d %s" % (e .errcode , e .errmsg ))
1149- # Detect redirect
11501147 redir = (e .headers and 'location' in e .headers )
11511148 if redir :
11521149 print ("\n Server was attempting a redirect. Try: "
11531150 " bugzilla --bugzilla %s ..." % redir )
11541151 sys .exit (4 )
11551152 except requests .exceptions .SSLError as e :
1156- log .debug ("" , exc_info = True )
1157-
11581153 # Give SSL recommendations
11591154 print ("SSL error: %s" % e )
11601155 print ("\n If you trust the remote server, you can work "
@@ -1164,6 +1159,13 @@ def main(unittest_bz_instance=None):
11641159 except (socket .error ,
11651160 requests .exceptions .HTTPError ,
11661161 requests .exceptions .ConnectionError ) as e :
1167- log .debug ("" , exc_info = True )
11681162 print ("\n Connection lost/failed: %s" % str (e ))
11691163 sys .exit (2 )
1164+
1165+ def cli ():
1166+ try :
1167+ main ()
1168+ except KeyboardInterrupt :
1169+ log .debug ("" , exc_info = True )
1170+ print ("\n Exited at user request." )
1171+ sys .exit (1 )
0 commit comments