~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Jelmer Vernooij
  • Date: 2011-01-11 04:33:12 UTC
  • mto: (5582.12.2 weave-plugin)
  • mto: This revision was merged to the branch mainline in revision 5718.
  • Revision ID: jelmer@samba.org-20110111043312-g4wx6iuf9662f36d
Move weave formats into bzrlib.plugins.weave_fmt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
713
713
       self.bzrdir = bzrdir
714
714
       PathError.__init__(self, path=path)
715
715
 
 
716
    def __repr__(self):
 
717
        return '<%s %r>' % (self.__class__.__name__, self.__dict__)
 
718
 
716
719
    def _format(self):
717
720
        # XXX: Ideally self.detail would be a property, but Exceptions in
718
721
        # Python 2.4 have to be old-style classes so properties don't work.
723
726
                    self.bzrdir.open_repository()
724
727
                except NoRepositoryPresent:
725
728
                    self.detail = ''
 
729
                except Exception:
 
730
                    # Just ignore unexpected errors.  Raising arbitrary errors
 
731
                    # during str(err) can provoke strange bugs.  Concretely
 
732
                    # Launchpad's codehosting managed to raise NotBranchError
 
733
                    # here, and then get stuck in an infinite loop/recursion
 
734
                    # trying to str() that error.  All this error really cares
 
735
                    # about that there's no working repository there, and if
 
736
                    # open_repository() fails, there probably isn't.
 
737
                    self.detail = ''
726
738
                else:
727
739
                    self.detail = ': location is a repository'
728
740
            else:
1072
1084
        self.target = target
1073
1085
 
1074
1086
 
 
1087
class LockCorrupt(LockError):
 
1088
 
 
1089
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
 
1090
            "Use 'bzr break-lock' to clear it")
 
1091
 
 
1092
    internal_error = False
 
1093
 
 
1094
    def __init__(self, corruption_info, file_data=None):
 
1095
        self.corruption_info = corruption_info
 
1096
        self.file_data = file_data
 
1097
 
 
1098
 
1075
1099
class LockNotHeld(LockError):
1076
1100
 
1077
1101
    _fmt = "Lock not held: %(lock)s"
1383
1407
 
1384
1408
class WeaveInvalidChecksum(WeaveError):
1385
1409
 
1386
 
    _fmt = "Text did not match it's checksum: %(msg)s"
 
1410
    _fmt = "Text did not match its checksum: %(msg)s"
1387
1411
 
1388
1412
 
1389
1413
class WeaveTextDiffers(WeaveError):
2933
2957
        self.user_encoding = osutils.get_user_encoding()
2934
2958
 
2935
2959
 
 
2960
class NoSuchConfig(BzrError):
 
2961
 
 
2962
    _fmt = ('The "%(config_id)s" configuration does not exist.')
 
2963
 
 
2964
    def __init__(self, config_id):
 
2965
        BzrError.__init__(self, config_id=config_id)
 
2966
 
 
2967
 
 
2968
class NoSuchConfigOption(BzrError):
 
2969
 
 
2970
    _fmt = ('The "%(option_name)s" configuration option does not exist.')
 
2971
 
 
2972
    def __init__(self, option_name):
 
2973
        BzrError.__init__(self, option_name=option_name)
 
2974
 
 
2975
 
2936
2976
class NoSuchAlias(BzrError):
2937
2977
 
2938
2978
    _fmt = ('The alias "%(alias_name)s" does not exist.')