~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Robert Collins
  • Date: 2005-11-22 21:28:30 UTC
  • mfrom: (1185.33.32 bzr.dev)
  • Revision ID: robertc@robertcollins.net-20051122212830-885c284847f0b17b
Merge from mpool.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
 * the printable form of an exception is generated by the base class
48
48
   __str__ method
 
49
 
 
50
Exception strings should start with a capital letter and not have a final
 
51
fullstop.
49
52
"""
50
53
 
51
54
# based on Scott James Remnant's hct error classes
157
160
        self.path = path
158
161
 
159
162
 
 
163
class FileInWrongBranch(BzrNewError):
 
164
    """File %(path)s in not in branch %(branch_base)s."""
 
165
    def __init__(self, branch, path):
 
166
        BzrNewError.__init__(self)
 
167
        self.branch = branch
 
168
        self.branch_base = branch.base
 
169
        self.path = path
 
170
 
 
171
 
160
172
class UnsupportedFormatError(BzrError):
161
173
    """Specified path is a bzr branch that we cannot read."""
162
174
    def __str__(self):
363
375
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
364
376
        IOError.__init__(self, errno.ENOENT, self.msg)
365
377
 
 
378
class ConnectionError(TransportError, IOError):
 
379
    """
 
380
    A connection problem prevents file retrieval.
 
381
    This does not indicate whether the file exists or not; it indicates that a
 
382
    precondition for requesting the file was not met.
 
383
    """
 
384
 
 
385
    # XXX: Is multiple inheritance for exceptions really needed?
 
386
 
 
387
    def __str__(self):
 
388
        return 'connection error: ' + self.msg
 
389
 
 
390
    def __init__(self, msg=None, orig_error=None):
 
391
        import errno
 
392
        TransportError.__init__(self, msg=msg, orig_error=orig_error)
 
393
        IOError.__init__(self, errno.ENOENT, self.msg)
 
394
 
 
395
 
366
396
class FileExists(TransportError, OSError):
367
397
    """An operation was attempted, which would overwrite an entry,
368
398
    but overwritting is not supported.
416
446
        BzrNewError.__init__(self)
417
447
        self.graph = graph
418
448
 
 
449
class NotConflicted(BzrNewError):
 
450
    """File %(filename)s is not conflicted."""
 
451
    def __init__(self, filename):
 
452
        BzrNewError.__init__(self)
 
453
        self.filename = filename
 
454
 
419
455
class MustUseDecorated(Exception):
420
456
    """A decorating function has requested its original command be used.
421
457