~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Lalo Martins
  • Date: 2005-09-15 15:28:33 UTC
  • mto: (1185.1.22)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: lalo@exoweb.net-20050915152832-1b23c36b1f0fffc4
made tests pass again, after merge from integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
class BzrError(StandardError):
26
26
    pass
27
27
 
 
28
 
28
29
class BzrCheckError(BzrError):
29
30
    pass
30
31
 
31
32
 
32
 
 
33
 
 
34
 
def bailout(msg, explanation=[]):
35
 
    ex = BzrError(msg, explanation)
36
 
    import trace
37
 
    trace._tracefile.write('* raising %s\n' % ex)
38
 
    raise ex
39
 
 
 
33
class InvalidRevisionNumber(BzrError):
 
34
    def __init__(self, revno):
 
35
        self.args = [revno]
 
36
        
 
37
    def __str__(self):
 
38
        return 'invalid revision number: %r' % self.args[0]
 
39
 
 
40
 
 
41
class InvalidRevisionId(BzrError):
 
42
    pass
 
43
 
 
44
 
 
45
class BzrCommandError(BzrError):
 
46
    # Error from malformed user command
 
47
    pass
 
48
 
 
49
 
 
50
class NotBranchError(BzrError):
 
51
    """Specified path is not in a branch"""
 
52
    pass
 
53
 
 
54
 
 
55
class NotVersionedError(BzrError):
 
56
    """Specified object is not versioned."""
 
57
 
 
58
 
 
59
class BadFileKindError(BzrError):
 
60
    """Specified file is of a kind that cannot be added.
 
61
 
 
62
    (For example a symlink or device file.)"""
 
63
    pass
 
64
 
 
65
 
 
66
class ForbiddenFileError(BzrError):
 
67
    """Cannot operate on a file because it is a control file."""
 
68
    pass
 
69
 
 
70
 
 
71
class LockError(Exception):
 
72
    """All exceptions from the lock/unlock functions should be from
 
73
    this exception class.  They will be translated as necessary. The
 
74
    original exception is available as e.original_error
 
75
    """
 
76
    def __init__(self, e=None):
 
77
        self.original_error = e
 
78
        if e:
 
79
            Exception.__init__(self, e)
 
80
        else:
 
81
            Exception.__init__(self)
 
82
 
 
83
 
 
84
class PointlessCommit(Exception):
 
85
    """Commit failed because nothing was changed."""
 
86
 
 
87
 
 
88
class NoSuchRevision(BzrError):
 
89
    def __init__(self, branch, revision):
 
90
        self.branch = branch
 
91
        self.revision = revision
 
92
        msg = "Branch %s has no revision %s" % (branch, revision)
 
93
        BzrError.__init__(self, msg)
 
94
 
 
95
 
 
96
class DivergedBranches(BzrError):
 
97
    def __init__(self, branch1, branch2):
 
98
        BzrError.__init__(self, "These branches have diverged.")
 
99
        self.branch1 = branch1
 
100
        self.branch2 = branch2
 
101
 
 
102
class UnrelatedBranches(BzrCommandError):
 
103
    def __init__(self):
 
104
        msg = "Branches have no common ancestor, and no base revision"\
 
105
            " specified."
 
106
        BzrCommandError.__init__(self, msg)
 
107
 
 
108
class NoCommonAncestor(BzrError):
 
109
    def __init__(self, revision_a, revision_b):
 
110
        msg = "Revisions have no common ancestor: %s %s." \
 
111
            % (revision_a, revision_b) 
 
112
        BzrError.__init__(self, msg)
 
113
 
 
114
class NoCommonRoot(BzrError):
 
115
    def __init__(self, revision_a, revision_b):
 
116
        msg = "Revisions are not derived from the same root: %s %s." \
 
117
            % (revision_a, revision_b) 
 
118
        BzrError.__init__(self, msg)
 
119
 
 
120
class NotAncestor(BzrError):
 
121
    def __init__(self, rev_id, not_ancestor_id):
 
122
        msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, 
 
123
                                                        rev_id)
 
124
        BzrError.__init__(self, msg)
 
125
        self.rev_id = rev_id
 
126
        self.not_ancestor_id = not_ancestor_id
 
127
 
 
128
 
 
129
class InstallFailed(BzrError):
 
130
    def __init__(self, revisions):
 
131
        msg = "Could not install revisions:\n%s" % " ,".join(revisions)
 
132
        BzrError.__init__(self, msg)
 
133
        self.revisions = revisions
 
134
 
 
135
 
 
136
class AmbiguousBase(BzrError):
 
137
    def __init__(self, bases):
 
138
        msg = "The correct base is unclear, becase %s are all equally close" %\
 
139
            ", ".join(bases)
 
140
        BzrError.__init__(self, msg)
 
141
        self.bases = bases
 
142
 
 
143
class NoCommits(BzrError):
 
144
    def __init__(self, branch):
 
145
        msg = "Branch %s has no commits." % branch
 
146
        BzrError.__init__(self, msg)