~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 12:14:01 UTC
  • mfrom: (1393.1.67)
  • Revision ID: robertc@robertcollins.net-20051006121401-ce87bcb93909bbdf
merge martins latest

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