~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-11 05:06:26 UTC
  • mto: (5050.45.2 2.2)
  • mto: This revision was merged to the branch mainline in revision 5524.
  • Revision ID: andrew.bennetts@canonical.com-20101011050626-kql01ndwvploy97a
Suppress unexpected errors during NotBranchError's call to open_repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
723
723
                    self.bzrdir.open_repository()
724
724
                except NoRepositoryPresent:
725
725
                    self.detail = ''
 
726
                except Exception:
 
727
                    # Just ignore unexpected errors.  Raising arbitrary errors
 
728
                    # during str(err) can provoke strange bugs.  Concretely
 
729
                    # Launchpad's codehosting managed to raise NotBranchError
 
730
                    # here, and then get stuck in an infinite loop/recursion
 
731
                    # trying to str() that error.  All this error really cares
 
732
                    # about that there's no working repository there, and if
 
733
                    # open_repository() fails, there probably isn't.
 
734
                    self.detail = ''
726
735
                else:
727
736
                    self.detail = ': location is a repository'
728
737
            else:
947
956
    # original exception is available as e.original_error
948
957
    #
949
958
    # New code should prefer to raise specific subclasses
950
 
    def __init__(self, message):
951
 
        # Python 2.5 uses a slot for StandardError.message,
952
 
        # so use a different variable name.  We now work around this in
953
 
        # BzrError.__str__, but this member name is kept for compatability.
954
 
        self.msg = message
 
959
    def __init__(self, msg):
 
960
        self.msg = msg
955
961
 
956
962
 
957
963
class LockActive(LockError):
1041
1047
class LockContention(LockError):
1042
1048
 
1043
1049
    _fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1044
 
    # TODO: show full url for lock, combining the transport and relative
1045
 
    # bits?
1046
1050
 
1047
1051
    internal_error = False
1048
1052
 
1075
1079
        self.target = target
1076
1080
 
1077
1081
 
 
1082
class LockCorrupt(LockError):
 
1083
 
 
1084
    _fmt = ("Lock is apparently held, but corrupted: %(corruption_info)s\n"
 
1085
            "Use 'bzr break-lock' to clear it")
 
1086
 
 
1087
    internal_error = False
 
1088
 
 
1089
    def __init__(self, corruption_info, file_data=None):
 
1090
        self.corruption_info = corruption_info
 
1091
        self.file_data = file_data
 
1092
 
 
1093
 
1078
1094
class LockNotHeld(LockError):
1079
1095
 
1080
1096
    _fmt = "Lock not held: %(lock)s"
1380
1396
 
1381
1397
class WeaveParentMismatch(WeaveError):
1382
1398
 
1383
 
    _fmt = "Parents are mismatched between two revisions. %(message)s"
 
1399
    _fmt = "Parents are mismatched between two revisions. %(msg)s"
1384
1400
 
1385
1401
 
1386
1402
class WeaveInvalidChecksum(WeaveError):
1387
1403
 
1388
 
    _fmt = "Text did not match it's checksum: %(message)s"
 
1404
    _fmt = "Text did not match it's checksum: %(msg)s"
1389
1405
 
1390
1406
 
1391
1407
class WeaveTextDiffers(WeaveError):
1439
1455
 
1440
1456
class VersionedFileInvalidChecksum(VersionedFileError):
1441
1457
 
1442
 
    _fmt = "Text did not match its checksum: %(message)s"
 
1458
    _fmt = "Text did not match its checksum: %(msg)s"
1443
1459
 
1444
1460
 
1445
1461
class KnitError(InternalBzrError):
1925
1941
    _fmt = "Moving the root directory is not supported at this time"
1926
1942
 
1927
1943
 
 
1944
class TransformRenameFailed(BzrError):
 
1945
 
 
1946
    _fmt = "Failed to rename %(from_path)s to %(to_path)s: %(why)s"
 
1947
 
 
1948
    def __init__(self, from_path, to_path, why, errno):
 
1949
        self.from_path = from_path
 
1950
        self.to_path = to_path
 
1951
        self.why = why
 
1952
        self.errno = errno
 
1953
 
 
1954
 
1928
1955
class BzrMoveFailedError(BzrError):
1929
1956
 
1930
1957
    _fmt = "Could not move %(from_path)s%(operator)s %(to_path)s%(extra)s"
2839
2866
        BzrError.__init__(self, tree=tree, display_url=display_url, more=more)
2840
2867
 
2841
2868
 
 
2869
class ShelvedChanges(UncommittedChanges):
 
2870
 
 
2871
    _fmt = ('Working tree "%(display_url)s" has shelved changes'
 
2872
            ' (See bzr shelve --list).%(more)s')
 
2873
 
 
2874
 
2842
2875
class MissingTemplateVariable(BzrError):
2843
2876
 
2844
2877
    _fmt = 'Variable {%(name)s} is not available.'
3134
3167
    def __init__(self, bzrdir):
3135
3168
        self.bzrdir = bzrdir
3136
3169
 
 
3170
 
 
3171
class NoWhoami(BzrError):
 
3172
 
 
3173
    _fmt = ('Unable to determine your name.\n'
 
3174
        "Please, set your name with the 'whoami' command.\n"
 
3175
        'E.g. bzr whoami "Your Name <name@example.com>"')
 
3176
 
 
3177
 
 
3178
class InvalidPattern(BzrError):
 
3179
 
 
3180
    _fmt = ('Invalid pattern(s) found. %(msg)s')
 
3181
 
 
3182
    def __init__(self, msg):
 
3183
        self.msg = msg
 
3184
 
 
3185
 
 
3186
class RecursiveBind(BzrError):
 
3187
 
 
3188
    _fmt = ('Branch "%(branch_url)s" appears to be bound to itself. '
 
3189
        'Please use `bzr unbind` to fix.')
 
3190
 
 
3191
    def __init__(self, branch_url):
 
3192
        self.branch_url = branch_url
 
3193