/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2007-09-24 06:42:21 UTC
  • mfrom: (2713.2.3 error-exitcode)
  • mto: This revision was merged to the branch mainline in revision 2874.
  • Revision ID: mbp@sourcefrog.net-20070924064221-nu12try0hbilenlj
Return exitcode 4 on internal error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
65
65
import bzrlib
66
66
 
67
67
lazy_import(globals(), """
68
 
from bzrlib import debug
 
68
from bzrlib import (
 
69
    debug,
 
70
    errors,
 
71
    )
69
72
""")
70
73
 
71
74
_file_handler = None
309
312
 
310
313
def report_exception(exc_info, err_file):
311
314
    """Report an exception to err_file (typically stderr) and to .bzr.log.
 
315
 
 
316
    This will show either a full traceback or a short message as appropriate.
 
317
 
 
318
    :return: The appropriate exit code for this error.
312
319
    """
313
320
    exc_type, exc_object, exc_tb = exc_info
314
321
    # Log the full traceback to ~/.bzr.log
316
323
    if (isinstance(exc_object, IOError)
317
324
        and getattr(exc_object, 'errno', None) == errno.EPIPE):
318
325
        print >>err_file, "bzr: broken pipe"
 
326
        return errors.EXIT_ERROR
319
327
    elif isinstance(exc_object, KeyboardInterrupt):
320
328
        print >>err_file, "bzr: interrupted"
 
329
        return errors.EXIT_ERROR
321
330
    elif not getattr(exc_object, 'internal_error', True):
322
331
        report_user_error(exc_info, err_file)
 
332
        return errors.EXIT_ERROR
323
333
    elif isinstance(exc_object, (OSError, IOError)):
324
334
        # Might be nice to catch all of these and show them as something more
325
335
        # specific, but there are too many cases at the moment.
326
336
        report_user_error(exc_info, err_file)
 
337
        return errors.EXIT_ERROR
327
338
    else:
328
339
        report_bug(exc_info, err_file)
 
340
        return errors.EXIT_INTERNAL_ERROR
329
341
 
330
342
 
331
343
# TODO: Should these be specially encoding the output?