~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Robert Collins
  • Date: 2005-10-06 07:11:13 UTC
  • mfrom: (1393.1.59)
  • Revision ID: robertc@robertcollins.net-20051006071113-54e61035470e2f49
mergeĀ fromĀ martin

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# exceptions 
24
24
class BzrError(StandardError):
25
25
    def __str__(self):
26
 
        # XXX: Should we show the exception class in 
27
 
        # exceptions that don't provide their own message?  
28
 
        # maybe it should be done at a higher level
29
 
        ## n = self.__class__.__name__ + ': '
30
 
        n = ''
31
26
        if len(self.args) == 1:
32
 
            return n + self.args[0]
 
27
            return self.args[0]
33
28
        elif len(self.args) == 2:
34
29
            # further explanation or suggestions
35
30
            try:
36
 
                return n + '\n  '.join([self.args[0]] + self.args[1])
 
31
                return '\n  '.join([self.args[0]] + self.args[1])
37
32
            except TypeError:
38
 
                return n + "%r" % self
 
33
                return "%r" % self
39
34
        else:
40
 
            return n + `self.args`
 
35
            return `self.args`
41
36
 
42
37
 
43
38
class BzrCheckError(BzrError):
55
50
 
56
51
class BzrCommandError(BzrError):
57
52
    # Error from malformed user command
58
 
    def __str__(self):
59
 
        return self.args[0]
 
53
    pass
60
54
 
61
55
 
62
56
class NotBranchError(BzrError):
63
57
    """Specified path is not in a branch"""
64
 
    def __str__(self):
65
 
        return 'not a branch: %s' % self.args[0]
 
58
    pass
66
59
 
67
60
 
68
61
class NotVersionedError(BzrError):
214
207
class NoSuchFile(TransportError, IOError):
215
208
    """A get() was issued for a file that doesn't exist."""
216
209
 
217
 
    # XXX: Is multiple inheritance for exceptions really needed?
218
 
 
219
210
    def __str__(self):
220
 
        return 'no such file: ' + self.msg
 
211
        return self.msg
221
212
 
222
213
    def __init__(self, msg=None, orig_error=None):
223
214
        import errno
230
221
 
231
222
    mkdir() can throw this, but put() just overwites existing files.
232
223
    """
233
 
    # XXX: Is multiple inheritance for exceptions really needed?
234
224
    def __init__(self, msg=None, orig_error=None):
235
225
        import errno
236
226
        TransportError.__init__(self, msg=msg, orig_error=orig_error)