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
145
150
def __str__(self):
146
151
return self.args[0]
153
158
class StrictCommitFailed(Exception):
154
159
"""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)
156
197
class NotBranchError(BzrNewError):
157
198
"""Not a branch: %(path)s"""
158
199
def __init__(self, path):
357
class NonRelativePath(TransportError):
358
"""An absolute path was supplied, that could not be decoded into
363
class NoSuchFile(TransportError, IOError):
364
"""A get() was issued for a file that doesn't exist."""
366
# XXX: Is multiple inheritance for exceptions really needed?
369
return 'no such file: ' + self.msg
371
def __init__(self, msg=None, orig_error=None):
373
TransportError.__init__(self, msg=msg, orig_error=orig_error)
374
IOError.__init__(self, errno.ENOENT, self.msg)
376
class ConnectionError(TransportError, IOError):
378
A connection problem prevents file retrieval.
399
class ConnectionError(TransportError):
400
"""A connection problem prevents file retrieval.
379
401
This does not indicate whether the file exists or not; it indicates that a
380
402
precondition for requesting the file was not met.
383
# XXX: Is multiple inheritance for exceptions really needed?
386
return 'connection error: ' + self.msg
388
def __init__(self, msg=None, orig_error=None):
390
TransportError.__init__(self, msg=msg, orig_error=orig_error)
391
IOError.__init__(self, errno.ENOENT, self.msg)
394
class FileExists(TransportError, OSError):
395
"""An operation was attempted, which would overwrite an entry,
396
but overwritting is not supported.
398
mkdir() can throw this, but put() just overwites existing files.
400
# XXX: Is multiple inheritance for exceptions really needed?
401
def __init__(self, msg=None, orig_error=None):
403
TransportError.__init__(self, msg=msg, orig_error=orig_error)
404
OSError.__init__(self, errno.EEXIST, self.msg)
406
class PermissionDenied(TransportError):
407
"""An operation cannot succeed because of a lack of permissions."""
404
def __init__(self, msg=None, orig_error=None):
405
TransportError.__init__(self, msg=msg, orig_error=orig_error)
410
408
class ConnectionReset(TransportError):
411
409
"""The connection has been closed."""