~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Martin Pool
  • Date: 2005-09-22 00:19:45 UTC
  • Revision ID: mbp@sourcefrog.net-20050922001945-04934f479aab6675
- more refactoring of check code

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
######################################################################
24
24
# exceptions 
25
25
class BzrError(StandardError):
26
 
    pass
 
26
    def __str__(self):
 
27
        if len(self.args) == 1:
 
28
            return self.args[0]
 
29
        elif len(self.args) == 2:
 
30
            # further explanation or suggestions
 
31
            return '\n  '.join([self.args[0]] + self.args[1])
 
32
        else:
 
33
            return `self.args`
 
34
 
27
35
 
28
36
class BzrCheckError(BzrError):
29
37
    pass
30
38
 
31
39
 
32
40
class InvalidRevisionNumber(BzrError):
33
 
    def __init__(self, revno):
34
 
        self.args = [revno]
35
 
        
36
41
    def __str__(self):
37
42
        return 'invalid revision number: %r' % self.args[0]
38
43
 
92
97
        BzrError.__init__(self, msg)
93
98
 
94
99
 
 
100
class HistoryMissing(BzrError):
 
101
    def __init__(self, branch, object_type, object_id):
 
102
        self.branch = branch
 
103
        BzrError.__init__(self,
 
104
                          '%s is missing %s {%s}'
 
105
                          % (branch, object_type, object_id))
 
106
 
 
107
 
95
108
class UnrelatedBranches(BzrCommandError):
96
109
    def __init__(self):
97
110
        msg = "Branches have no common ancestor, and no base revision"\