~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2006-06-04 21:45:02 UTC
  • mto: This revision was merged to the branch mainline in revision 1797.
  • Revision ID: mbp@sourcefrog.net-20060604214502-a47830087e90a3e1
Improved tests for display of exceptions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
        enable_default_logging()
257
257
 
258
258
 
259
 
def report_unhandled_exception(exc_info, err_file):
260
 
    """Report to stderr than an exception hit the top level.
261
 
 
262
 
    This is used only for exceptions that indicate a bug of some kind in bzr.
263
 
    """
 
259
def report_exception(exc_info, err_file):
264
260
    if isinstance(exc_info[1], (BzrError, BzrNewError)):
265
261
        report_user_error(exc_info, err_file)
266
262
    else:
270
266
# TODO: Should these be specially encoding the output?
271
267
def report_user_error(exc_info, err_file):
272
268
    exc_type, exc_object, exc_tb = exc_info
273
 
    print >>err_file, "bzr:",
 
269
    print >>err_file, "bzr: ERROR:",
274
270
    try:
275
271
        print >>err_file, str(exc_object)
276
272
    except Exception, formatting_exc:
281
277
 
282
278
 
283
279
def report_bug(exc_info, err_file):
 
280
    """Report an exception that probably indicates a bug in bzr"""
284
281
    import traceback
285
282
    exc_type, exc_object, exc_tb = exc_info
286
283
    print >>err_file, "bzr: unhandled error: %s: %s" % (exc_type, exc_object)
287
284
    print >>err_file
288
 
    traceback.print_exception(*exc_info)
 
285
    traceback.print_exception(exc_type, exc_object, exc_tb, file=err_file)
289
286
    print >>err_file
290
287
    print >>err_file, "** please send this report to bazaar-ng@lists.ubuntu.com"
291
288