142
142
# Error from malformed user command
143
143
# This is being misused as a generic exception
144
144
# pleae subclass. RBC 20051030
146
# I think it's a waste of effort to differentiate between errors that
147
# are not intended to be caught anyway. UI code need not subclass
148
# BzrCommandError, and non-UI code should not throw a subclass of
149
# BzrCommandError. ADHB 20051211
150
145
def __str__(self):
151
146
return self.args[0]
158
153
class StrictCommitFailed(Exception):
159
154
"""Commit refused because there are unknowns in the tree."""
162
class PathError(BzrNewError):
163
"""Generic path error: %(path)r%(extra)s)"""
164
def __init__(self, path, extra=None):
165
BzrNewError.__init__(self)
168
self.extra = ': ' + str(extra)
173
class NoSuchFile(PathError):
174
"""No such file: %(path)r%(extra)s"""
177
class FileExists(PathError):
178
"""File exists: %(path)r%(extra)s"""
181
class PermissionDenied(PathError):
182
"""Permission denied: %(path)r%(extra)s"""
185
class PathNotChild(BzrNewError):
186
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
187
def __init__(self, path, base, extra=None):
188
BzrNewError.__init__(self)
192
self.extra = ': ' + str(extra)
197
156
class NotBranchError(BzrNewError):
198
157
"""Not a branch: %(path)s"""
199
158
def __init__(self, path):
370
329
"""Parents are mismatched between two revisions."""
373
class NoSuchExportFormat(BzrNewError):
374
"""Export format %(format)r not supported"""
375
def __init__(self, format):
376
BzrNewError.__init__(self)
380
332
class TransportError(BzrError):
381
333
"""All errors thrown by Transport implementations should derive
399
class ConnectionError(TransportError):
400
"""A connection problem prevents file retrieval.
350
class NonRelativePath(TransportError):
351
"""An absolute path was supplied, that could not be decoded into
356
class NoSuchFile(TransportError, IOError):
357
"""A get() was issued for a file that doesn't exist."""
359
# XXX: Is multiple inheritance for exceptions really needed?
362
return 'no such file: ' + self.msg
364
def __init__(self, msg=None, orig_error=None):
366
TransportError.__init__(self, msg=msg, orig_error=orig_error)
367
IOError.__init__(self, errno.ENOENT, self.msg)
369
class ConnectionError(TransportError, IOError):
371
A connection problem prevents file retrieval.
401
372
This does not indicate whether the file exists or not; it indicates that a
402
373
precondition for requesting the file was not met.
404
def __init__(self, msg=None, orig_error=None):
405
TransportError.__init__(self, msg=msg, orig_error=orig_error)
376
# XXX: Is multiple inheritance for exceptions really needed?
379
return 'connection error: ' + self.msg
381
def __init__(self, msg=None, orig_error=None):
383
TransportError.__init__(self, msg=msg, orig_error=orig_error)
384
IOError.__init__(self, errno.ENOENT, self.msg)
387
class FileExists(TransportError, OSError):
388
"""An operation was attempted, which would overwrite an entry,
389
but overwritting is not supported.
391
mkdir() can throw this, but put() just overwites existing files.
393
# XXX: Is multiple inheritance for exceptions really needed?
394
def __init__(self, msg=None, orig_error=None):
396
TransportError.__init__(self, msg=msg, orig_error=orig_error)
397
OSError.__init__(self, errno.EEXIST, self.msg)
399
class PermissionDenied(TransportError):
400
"""An operation cannot succeed because of a lack of permissions."""
408
403
class ConnectionReset(TransportError):
409
404
"""The connection has been closed."""