[Pkg-bazaar-commits] ./bzr/unstable r263: factor out code to log exceptions

Martin Pool mbp at sourcefrog.net
Fri Apr 10 07:51:35 UTC 2009


------------------------------------------------------------
revno: 263
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-04-15 12:55:00 +1000
message:
  factor out code to log exceptions
modified:
  bzrlib/commands.py
  bzrlib/trace.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py	2005-04-15 02:41:52 +0000
+++ b/bzrlib/commands.py	2005-04-15 02:55:00 +0000
@@ -62,7 +62,7 @@
 
 
 
-import sys, os, time, types, shutil, tempfile, traceback, fnmatch, difflib, os.path
+import sys, os, time, types, shutil, tempfile, fnmatch, difflib, os.path
 from sets import Set
 from pprint import pprint
 from stat import *
@@ -1012,12 +1012,6 @@
 
 
 def main(argv):
-    ## TODO: Handle command-line options; probably know what options are valid for
-    ## each command
-
-    ## TODO: If the arguments are wrong, give a usage message rather
-    ## than just a backtrace.
-
     bzrlib.trace.create_tracefile(argv)
 
     try:
@@ -1029,14 +1023,13 @@
             if len(e.args) > 1:
                 for h in e.args[1]:
                     log_error('  ' + h)
-            traceback.print_exc(None, bzrlib.trace._tracefile)
-            log_error('(see ~/.bzr.log for debug information)')
+            bzrlib.trace.log_exception(e)
+            sys.stderr.write('(see ~/.bzr.log for debug information)\n')
             return 1
         except Exception, e:
             log_error('bzr: exception: %s' % str(e).rstrip('\n'))
-            log_error('(see $HOME/.bzr.log for debug information)')
-            traceback.print_exc(None, bzrlib.trace._tracefile)
-            ## traceback.print_exc(None, sys.stderr)
+            sys.stderr.write('(see $HOME/.bzr.log for debug information)\n')
+            bzrlib.trace.log_exception(e)
             return 1
     finally:
         bzrlib.trace.close_trace()

=== modified file 'bzrlib/trace.py'
--- a/bzrlib/trace.py	2005-04-15 02:50:12 +0000
+++ b/bzrlib/trace.py	2005-04-15 02:55:00 +0000
@@ -143,3 +143,7 @@
 
 
 
+def log_exception(e):
+    import traceback
+    traceback.print_exc(None, _tracefile)
+    



More information about the Pkg-bazaar-commits mailing list