142
144
# Error from malformed user command
143
145
# This is being misused as a generic exception
144
146
# pleae subclass. RBC 20051030
148
# I think it's a waste of effort to differentiate between errors that
149
# are not intended to be caught anyway. UI code need not subclass
150
# BzrCommandError, and non-UI code should not throw a subclass of
151
# BzrCommandError. ADHB 20051211
145
152
def __str__(self):
146
153
return self.args[0]
153
160
class StrictCommitFailed(Exception):
154
161
"""Commit refused because there are unknowns in the tree."""
164
class PathError(BzrNewError):
165
"""Generic path error: %(path)r%(extra)s)"""
166
def __init__(self, path, extra=None):
167
BzrNewError.__init__(self)
170
self.extra = ': ' + str(extra)
175
class NoSuchFile(PathError):
176
"""No such file: %(path)r%(extra)s"""
179
class FileExists(PathError):
180
"""File exists: %(path)r%(extra)s"""
183
class PermissionDenied(PathError):
184
"""Permission denied: %(path)r%(extra)s"""
187
class PathNotChild(BzrNewError):
188
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
189
def __init__(self, path, base, extra=None):
190
BzrNewError.__init__(self)
194
self.extra = ': ' + str(extra)
156
199
class NotBranchError(BzrNewError):
157
200
"""Not a branch: %(path)s"""
158
201
def __init__(self, path):
267
310
self.not_ancestor_id = not_ancestor_id
270
class NotAncestor(BzrError):
271
def __init__(self, rev_id, not_ancestor_id):
273
self.not_ancestor_id = not_ancestor_id
274
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
276
BzrError.__init__(self, msg)
279
313
class InstallFailed(BzrError):
280
314
def __init__(self, revisions):
281
315
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
338
372
"""Parents are mismatched between two revisions."""
375
class WeaveInvalidChecksum(WeaveError):
376
"""Text did not match it's checksum: %(message)s"""
379
class NoSuchExportFormat(BzrNewError):
380
"""Export format %(format)r not supported"""
381
def __init__(self, format):
382
BzrNewError.__init__(self)
341
386
class TransportError(BzrError):
342
387
"""All errors thrown by Transport implementations should derive
359
class NonRelativePath(TransportError):
360
"""An absolute path was supplied, that could not be decoded into
365
class NoSuchFile(TransportError, IOError):
366
"""A get() was issued for a file that doesn't exist."""
368
# XXX: Is multiple inheritance for exceptions really needed?
371
return 'no such file: ' + self.msg
373
def __init__(self, msg=None, orig_error=None):
375
TransportError.__init__(self, msg=msg, orig_error=orig_error)
376
IOError.__init__(self, errno.ENOENT, self.msg)
378
class ConnectionError(TransportError, IOError):
380
A connection problem prevents file retrieval.
405
class ConnectionError(TransportError):
406
"""A connection problem prevents file retrieval.
381
407
This does not indicate whether the file exists or not; it indicates that a
382
408
precondition for requesting the file was not met.
385
# XXX: Is multiple inheritance for exceptions really needed?
388
return 'connection error: ' + self.msg
390
def __init__(self, msg=None, orig_error=None):
392
TransportError.__init__(self, msg=msg, orig_error=orig_error)
393
IOError.__init__(self, errno.ENOENT, self.msg)
396
class FileExists(TransportError, OSError):
397
"""An operation was attempted, which would overwrite an entry,
398
but overwritting is not supported.
400
mkdir() can throw this, but put() just overwites existing files.
402
# XXX: Is multiple inheritance for exceptions really needed?
403
def __init__(self, msg=None, orig_error=None):
405
TransportError.__init__(self, msg=msg, orig_error=orig_error)
406
OSError.__init__(self, errno.EEXIST, self.msg)
408
class PermissionDenied(TransportError):
409
"""An operation cannot succeed because of a lack of permissions."""
410
def __init__(self, msg=None, orig_error=None):
411
TransportError.__init__(self, msg=msg, orig_error=orig_error)
412
414
class ConnectionReset(TransportError):
413
415
"""The connection has been closed."""
446
448
BzrNewError.__init__(self)
447
449
self.graph = graph
449
452
class NotConflicted(BzrNewError):
450
453
"""File %(filename)s is not conflicted."""
451
455
def __init__(self, filename):
452
456
BzrNewError.__init__(self)
453
457
self.filename = filename
455
460
class MustUseDecorated(Exception):
456
461
"""A decorating function has requested its original command be used.
461
466
class MissingText(BzrNewError):
462
467
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
463
469
def __init__(self, branch, text_revision, file_id):
470
BzrNewError.__init__(self)
464
471
self.branch = branch
465
472
self.base = branch.base
466
473
self.text_revision = text_revision
467
474
self.file_id = file_id
477
class BzrBadParameter(BzrNewError):
478
"""Parameter %(param)s is neither unicode nor utf8."""
480
def __init__(self, param):
481
BzrNewError.__init__(self)