50
54
Base class for errors raised by bzrlib.
52
56
:cvar internal_error: if True this was probably caused by a bzr bug and
53
should be displayed with a traceback; if False (or absent) this was
54
probably a user or environment error and they don't need the gory
55
details. (That can be overridden by -Derror on the command line.)
57
should be displayed with a traceback; if False (or absent) this was
58
probably a user or environment error and they don't need the gory details.
59
(That can be overridden by -Derror on the command line.)
57
61
:cvar _fmt: Format string to display the error; this is expanded
58
by the instance's dict.
62
by the instance's dict.
61
65
internal_error = False
136
140
"""Return format string for this exception or None"""
137
141
fmt = getattr(self, '_fmt', None)
138
142
if fmt is not None:
140
unicode_fmt = unicode(fmt) #_fmt strings should be ascii
141
if type(fmt) == unicode:
142
trace.mutter("Unicode strings in error.fmt are deprecated")
143
return gettext(unicode_fmt)
144
144
fmt = getattr(self, '__doc__', None)
145
145
if fmt is not None:
146
146
symbol_versioning.warn("%s uses its docstring as a format, "
622
622
_fmt = 'Unsupported protocol for url "%(path)s"%(extra)s'
624
def __init__(self, url, extra=""):
624
def __init__(self, url, extra):
625
625
PathError.__init__(self, url, extra=extra)
864
864
"""Construct a new AlreadyVersionedError.
866
866
:param path: This is the path which is versioned,
867
which should be in a user friendly form.
867
which should be in a user friendly form.
868
868
:param context_info: If given, this is information about the context,
869
which could explain why this is expected to not be versioned.
869
which could explain why this is expected to not be versioned.
871
871
BzrError.__init__(self)
885
885
"""Construct a new NotVersionedError.
887
887
:param path: This is the path which is not versioned,
888
which should be in a user friendly form.
888
which should be in a user friendly form.
889
889
:param context_info: If given, this is information about the context,
890
which could explain why this is expected to be versioned.
890
which could explain why this is expected to be versioned.
892
892
BzrError.__init__(self)
1723
1716
class InvalidHttpResponse(TransportError):
1725
_fmt = "Invalid http response for %(path)s: %(msg)s%(orig_error)s"
1718
_fmt = "Invalid http response for %(path)s: %(msg)s"
1727
1720
def __init__(self, path, msg, orig_error=None):
1728
1721
self.path = path
1729
if orig_error is None:
1732
# This is reached for obscure and unusual errors so we want to
1733
# preserve as much info as possible to ease debug.
1734
orig_error = ': %r' % (orig_error,)
1735
1722
TransportError.__init__(self, msg, orig_error=orig_error)
1744
1731
InvalidHttpResponse.__init__(self, path, msg)
1747
class HttpBoundaryMissing(InvalidHttpResponse):
1748
"""A multipart response ends with no boundary marker.
1750
This is a special case caused by buggy proxies, described in
1751
<https://bugs.launchpad.net/bzr/+bug/198646>.
1754
_fmt = "HTTP MIME Boundary missing for %(path)s: %(msg)s"
1756
def __init__(self, path, msg):
1757
InvalidHttpResponse.__init__(self, path, msg)
1760
1734
class InvalidHttpContentType(InvalidHttpResponse):
1762
1736
_fmt = 'Invalid http Content-type "%(ctype)s" for %(path)s: %(msg)s'
1790
1764
_fmt = "Working tree has conflicts."
1793
class ConfigContentError(BzrError):
1795
_fmt = "Config file %(filename)s is not UTF-8 encoded\n"
1797
def __init__(self, filename):
1798
BzrError.__init__(self)
1799
self.filename = filename
1802
1767
class ParseConfigError(BzrError):
1804
_fmt = "Error(s) parsing config file %(filename)s:\n%(errors)s"
1806
1769
def __init__(self, errors, filename):
1807
BzrError.__init__(self)
1808
self.filename = filename
1809
self.errors = '\n'.join(e.msg for e in errors)
1812
class ConfigOptionValueError(BzrError):
1814
_fmt = """Bad value "%(value)s" for option "%(name)s"."""
1816
def __init__(self, name, value):
1817
BzrError.__init__(self, name=name, value=value)
1770
if filename is None:
1772
message = "Error(s) parsing config file %s:\n%s" % \
1773
(filename, ('\n'.join(e.msg for e in errors)))
1774
BzrError.__init__(self, message)
1820
1777
class NoEmailInUsername(BzrError):
1829
1786
class SigningFailed(BzrError):
1831
_fmt = 'Failed to GPG sign data with command "%(command_line)s"'
1788
_fmt = 'Failed to gpg sign data with command "%(command_line)s"'
1833
1790
def __init__(self, command_line):
1834
1791
BzrError.__init__(self, command_line=command_line)
1837
class SignatureVerificationFailed(BzrError):
1839
_fmt = 'Failed to verify GPG signature data with error "%(error)s"'
1841
def __init__(self, error):
1842
BzrError.__init__(self, error=error)
1845
class DependencyNotPresent(BzrError):
1847
_fmt = 'Unable to import library "%(library)s": %(error)s'
1849
def __init__(self, library, error):
1850
BzrError.__init__(self, library=library, error=error)
1853
class GpgmeNotInstalled(DependencyNotPresent):
1855
_fmt = 'python-gpgme is not installed, it is needed to verify signatures'
1857
def __init__(self, error):
1858
DependencyNotPresent.__init__(self, 'gpgme', error)
1861
1794
class WorkingTreeNotRevision(BzrError):
1863
1796
_fmt = ("The working tree for %(basedir)s has changed since"
2116
2049
_fmt = "Parameter %(param)s contains a newline."
2052
class DependencyNotPresent(BzrError):
2054
_fmt = 'Unable to import library "%(library)s": %(error)s'
2056
def __init__(self, library, error):
2057
BzrError.__init__(self, library=library, error=error)
2119
2060
class ParamikoNotPresent(DependencyNotPresent):
2121
2062
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
2733
2666
This is distinct from ErrorFromSmartServer so that it is possible to
2734
2667
distinguish between the following two cases:
2736
- ErrorFromSmartServer was uncaught. This is logic error in the client
2737
and so should provoke a traceback to the user.
2738
- ErrorFromSmartServer was caught but its error_tuple could not be
2739
translated. This is probably because the server sent us garbage, and
2740
should not provoke a traceback.
2668
- ErrorFromSmartServer was uncaught. This is logic error in the client
2669
and so should provoke a traceback to the user.
2670
- ErrorFromSmartServer was caught but its error_tuple could not be
2671
translated. This is probably because the server sent us garbage, and
2672
should not provoke a traceback.
2743
2675
_fmt = "Server sent an unexpected error: %(error_tuple)r"
3142
3074
_fmt = "Shelf corrupt."
3145
class DecompressCorruption(BzrError):
3147
_fmt = "Corruption while decompressing repository file%(orig_error)s"
3149
def __init__(self, orig_error=None):
3150
if orig_error is not None:
3151
self.orig_error = ", %s" % (orig_error,)
3153
self.orig_error = ""
3154
BzrError.__init__(self)
3157
3077
class NoSuchShelfId(BzrError):
3159
3079
_fmt = 'No changes are shelved with id "%(shelf_id)d".'
3329
3249
def __init__(self, name, string):
3330
3250
self.name = name
3331
3251
self.string = string
3334
class NoCompatibleInter(BzrError):
3336
_fmt = ('No compatible object available for operations from %(source)r '
3339
def __init__(self, source, target):
3340
self.source = source
3341
self.target = target
3344
class HpssVfsRequestNotAllowed(BzrError):
3346
_fmt = ("VFS requests over the smart server are not allowed. Encountered: "
3347
"%(method)s, %(arguments)s.")
3349
def __init__(self, method, arguments):
3350
self.method = method
3351
self.arguments = arguments
3354
class UnsupportedKindChange(BzrError):
3356
_fmt = ("Kind change from %(from_kind)s to %(to_kind)s for "
3357
"%(path)s not supported by format %(format)r")
3359
def __init__(self, path, from_kind, to_kind, format):
3361
self.from_kind = from_kind
3362
self.to_kind = to_kind
3363
self.format = format
3366
class PatchSyntax(BzrError):
3367
"""Base class for patch syntax errors."""
3370
class BinaryFiles(BzrError):
3372
_fmt = 'Binary files section encountered.'
3374
def __init__(self, orig_name, mod_name):
3375
self.orig_name = orig_name
3376
self.mod_name = mod_name
3379
class MalformedPatchHeader(PatchSyntax):
3381
_fmt = "Malformed patch header. %(desc)s\n%(line)r"
3383
def __init__(self, desc, line):
3388
class MalformedHunkHeader(PatchSyntax):
3390
_fmt = "Malformed hunk header. %(desc)s\n%(line)r"
3392
def __init__(self, desc, line):
3397
class MalformedLine(PatchSyntax):
3399
_fmt = "Malformed line. %(desc)s\n%(line)r"
3401
def __init__(self, desc, line):
3406
class PatchConflict(BzrError):
3408
_fmt = ('Text contents mismatch at line %(line_no)d. Original has '
3409
'"%(orig_line)s", but patch says it should be "%(patch_line)s"')
3411
def __init__(self, line_no, orig_line, patch_line):
3412
self.line_no = line_no
3413
self.orig_line = orig_line.rstrip('\n')
3414
self.patch_line = patch_line.rstrip('\n')