~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Robert Collins
  • Date: 2007-09-28 00:50:33 UTC
  • mto: (2592.3.161 repository)
  • mto: This revision was merged to the branch mainline in revision 2872.
  • Revision ID: robertc@robertcollins.net-20070928005033-k2aj7takjzzfo3vn
* New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
  shorthand for deriving from BzrError and setting internal_error = True.
  (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
               )
131
131
 
132
132
 
 
133
class InternalBzrError(BzrError):
 
134
    """Base class for errors that are internal in nature.
 
135
 
 
136
    This is a convenience class for errors that are internal. The
 
137
    internal_error attribute can still be altered in subclasses, if needed.
 
138
    Using this class is simply an easy way to get internal errors.
 
139
    """
 
140
 
 
141
    internal_error = True
 
142
 
 
143
 
133
144
class BzrNewError(BzrError):
134
145
    """Deprecated error base class."""
135
146
    # base classes should override the docstring with their human-
168
179
    _fmt = "The tree builder is already building a tree."
169
180
 
170
181
 
171
 
class BzrCheckError(BzrError):
 
182
class BzrCheckError(InternalBzrError):
172
183
    
173
184
    _fmt = "Internal check failed: %(message)s"
174
185
 
175
 
    internal_error = True
176
 
 
177
186
    def __init__(self, message):
178
187
        BzrError.__init__(self)
179
188
        self.message = message
180
189
 
181
190
 
182
 
class DisabledMethod(BzrError):
 
191
class DisabledMethod(InternalBzrError):
183
192
 
184
193
    _fmt = "The smart server method '%(class_name)s' is disabled."
185
194
 
186
 
    internal_error = True
187
 
 
188
195
    def __init__(self, class_name):
189
196
        BzrError.__init__(self)
190
197
        self.class_name = class_name
211
218
        self.transport = transport
212
219
 
213
220
 
214
 
class InvalidEntryName(BzrError):
 
221
class InvalidEntryName(InternalBzrError):
215
222
    
216
223
    _fmt = "Invalid entry name: %(name)s"
217
224
 
218
 
    internal_error = True
219
 
 
220
225
    def __init__(self, name):
221
226
        BzrError.__init__(self)
222
227
        self.name = name
277
282
        BzrError.__init__(self, repository=repository, file_id=file_id)
278
283
 
279
284
 
280
 
class InventoryModified(BzrError):
 
285
class InventoryModified(InternalBzrError):
281
286
 
282
287
    _fmt = ("The current inventory for the tree %(tree)r has been modified,"
283
288
            " so a clean inventory cannot be read without data loss.")
284
289
 
285
 
    internal_error = True
286
 
 
287
290
    def __init__(self, tree):
288
291
        self.tree = tree
289
292
 
310
313
        self.url = url
311
314
 
312
315
 
313
 
class WorkingTreeAlreadyPopulated(BzrError):
 
316
class WorkingTreeAlreadyPopulated(InternalBzrError):
314
317
 
315
318
    _fmt = 'Working tree already populated in "%(base)s"'
316
319
 
317
 
    internal_error = True
318
 
 
319
320
    def __init__(self, base):
320
321
        self.base = base
321
322
 
 
323
 
322
324
class BzrCommandError(BzrError):
323
325
    """Error from user command"""
324
326
 
325
 
    internal_error = False
326
 
 
327
327
    # Error from malformed user command; please avoid raising this as a
328
328
    # generic exception not caused by user input.
329
329
    #
485
485
    _fmt = 'Directory not empty: "%(path)s"%(extra)s'
486
486
 
487
487
 
488
 
class ReadingCompleted(BzrError):
 
488
class ReadingCompleted(InternalBzrError):
489
489
    
490
490
    _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
491
491
            "called upon it - the request has been completed and no more "
492
492
            "data may be read.")
493
493
 
494
 
    internal_error = True
495
 
 
496
494
    def __init__(self, request):
497
495
        self.request = request
498
496
 
774
772
    _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
775
773
 
776
774
 
777
 
class LockError(BzrError):
 
775
class LockError(InternalBzrError):
778
776
 
779
777
    _fmt = "Lock error: %(msg)s"
780
778
 
781
 
    internal_error = True
782
 
 
783
779
    # All exceptions from the lock/unlock functions should be from
784
780
    # this exception class.  They will be translated as necessary. The
785
781
    # original exception is available as e.original_error
922
918
 
923
919
    _fmt = "The object %(obj)s does not support token specifying a token when locking."
924
920
 
925
 
    internal_error = True
926
 
 
927
921
    def __init__(self, obj):
928
922
        self.obj = obj
929
923
 
979
973
    _fmt = "Commit refused because there are unknowns in the tree."
980
974
 
981
975
 
982
 
class NoSuchRevision(BzrError):
 
976
class NoSuchRevision(InternalBzrError):
983
977
 
984
978
    _fmt = "%(branch)s has no revision %(revision)s"
985
979
 
986
 
    internal_error = True
987
 
 
988
980
    def __init__(self, branch, revision):
989
981
        # 'branch' may sometimes be an internal object like a KnitRevisionStore
990
982
        BzrError.__init__(self, branch=branch, revision=revision)
991
983
 
992
984
 
993
985
# zero_ninetyone: this exception is no longer raised and should be removed
994
 
class NotLeftParentDescendant(BzrError):
 
986
class NotLeftParentDescendant(InternalBzrError):
995
987
 
996
988
    _fmt = ("Revision %(old_revision)s is not the left parent of"
997
989
            " %(new_revision)s, but branch %(branch_location)s expects this")
998
990
 
999
 
    internal_error = True
1000
 
 
1001
991
    def __init__(self, branch, old_revision, new_revision):
1002
992
        BzrError.__init__(self, branch_location=branch.base,
1003
993
                          old_revision=old_revision,
1063
1053
    _fmt = ("These branches have diverged."
1064
1054
            " Use the merge command to reconcile them.")
1065
1055
 
1066
 
    internal_error = False
1067
 
 
1068
1056
    def __init__(self, branch1, branch2):
1069
1057
        self.branch1 = branch1
1070
1058
        self.branch2 = branch2
1071
1059
 
1072
1060
 
1073
 
class NotLefthandHistory(BzrError):
 
1061
class NotLefthandHistory(InternalBzrError):
1074
1062
 
1075
1063
    _fmt = "Supplied history does not follow left-hand parents"
1076
1064
 
1077
 
    internal_error = True
1078
 
 
1079
1065
    def __init__(self, history):
1080
1066
        BzrError.__init__(self, history=history)
1081
1067
 
1085
1071
    _fmt = ("Branches have no common ancestor, and"
1086
1072
            " no merge base revision was specified.")
1087
1073
 
1088
 
    internal_error = False
1089
 
 
1090
1074
 
1091
1075
class NoCommonAncestor(BzrError):
1092
1076
    
1303
1287
    _fmt = "Text did not match its checksum: %(message)s"
1304
1288
 
1305
1289
 
1306
 
class KnitError(BzrError):
 
1290
class KnitError(InternalBzrError):
1307
1291
    
1308
1292
    _fmt = "Knit error"
1309
1293
 
1310
 
    internal_error = True
1311
 
 
1312
1294
 
1313
1295
class KnitCorrupt(KnitError):
1314
1296
 
1378
1360
        BzrError.__init__(self)
1379
1361
 
1380
1362
 
1381
 
class TooManyConcurrentRequests(BzrError):
 
1363
class TooManyConcurrentRequests(InternalBzrError):
1382
1364
 
1383
1365
    _fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
1384
1366
            " Be sure to finish_writing and finish_reading on the"
1385
1367
            " currently open request.")
1386
1368
 
1387
 
    internal_error = True
1388
 
 
1389
1369
    def __init__(self, medium):
1390
1370
        self.medium = medium
1391
1371
 
1581
1561
        self.graph = graph
1582
1562
 
1583
1563
 
1584
 
class WritingCompleted(BzrError):
 
1564
class WritingCompleted(InternalBzrError):
1585
1565
 
1586
1566
    _fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1587
1567
            "called upon it - accept bytes may not be called anymore.")
1588
1568
 
1589
 
    internal_error = True
1590
 
 
1591
1569
    def __init__(self, request):
1592
1570
        self.request = request
1593
1571
 
1594
1572
 
1595
 
class WritingNotComplete(BzrError):
 
1573
class WritingNotComplete(InternalBzrError):
1596
1574
 
1597
1575
    _fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1598
1576
            "called upon it - until the write phase is complete no "
1599
1577
            "data may be read.")
1600
1578
 
1601
 
    internal_error = True
1602
 
 
1603
1579
    def __init__(self, request):
1604
1580
        self.request = request
1605
1581
 
1613
1589
        self.filename = filename
1614
1590
 
1615
1591
 
1616
 
class MediumNotConnected(BzrError):
 
1592
class MediumNotConnected(InternalBzrError):
1617
1593
 
1618
1594
    _fmt = """The medium '%(medium)s' is not connected."""
1619
1595
 
1620
 
    internal_error = True
1621
 
 
1622
1596
    def __init__(self, medium):
1623
1597
        self.medium = medium
1624
1598
 
1700
1674
        self.root_trans_id = transform.root
1701
1675
 
1702
1676
 
1703
 
class BzrBadParameter(BzrError):
 
1677
class BzrBadParameter(InternalBzrError):
1704
1678
 
1705
1679
    _fmt = "Bad parameter: %(param)r"
1706
1680
 
1707
 
    internal_error = True
1708
 
 
1709
1681
    # This exception should never be thrown, but it is a base class for all
1710
1682
    # parameter-to-function errors.
1711
1683
 
2094
2066
    _fmt = """This operation requires rich root data storage"""
2095
2067
 
2096
2068
 
2097
 
class NoSmartMedium(BzrError):
 
2069
class NoSmartMedium(InternalBzrError):
2098
2070
 
2099
2071
    _fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
2100
2072
 
2101
 
    internal_error = True
2102
 
 
2103
2073
    def __init__(self, transport):
2104
2074
        self.transport = transport
2105
2075
 
2136
2106
        self.revision_id = revision_id
2137
2107
 
2138
2108
 
2139
 
class IllegalUseOfScopeReplacer(BzrError):
 
2109
class IllegalUseOfScopeReplacer(InternalBzrError):
2140
2110
 
2141
2111
    _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
2142
2112
            " %(msg)s%(extra)s")
2143
2113
 
2144
 
    internal_error = True
2145
 
 
2146
2114
    def __init__(self, name, msg, extra=None):
2147
2115
        BzrError.__init__(self)
2148
2116
        self.name = name
2153
2121
            self.extra = ''
2154
2122
 
2155
2123
 
2156
 
class InvalidImportLine(BzrError):
 
2124
class InvalidImportLine(InternalBzrError):
2157
2125
 
2158
2126
    _fmt = "Not a valid import statement: %(msg)\n%(text)s"
2159
2127
 
2160
 
    internal_error = True
2161
 
 
2162
2128
    def __init__(self, text, msg):
2163
2129
        BzrError.__init__(self)
2164
2130
        self.text = text
2165
2131
        self.msg = msg
2166
2132
 
2167
2133
 
2168
 
class ImportNameCollision(BzrError):
 
2134
class ImportNameCollision(InternalBzrError):
2169
2135
 
2170
2136
    _fmt = ("Tried to import an object to the same name as"
2171
2137
            " an existing object. %(name)s")
2172
2138
 
2173
 
    internal_error = True
2174
 
 
2175
2139
    def __init__(self, name):
2176
2140
        BzrError.__init__(self)
2177
2141
        self.name = name
2242
2206
        self.other_tree = other_tree
2243
2207
 
2244
2208
 
2245
 
class BadReferenceTarget(BzrError):
 
2209
class BadReferenceTarget(InternalBzrError):
2246
2210
 
2247
2211
    _fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
2248
2212
           "%(reason)s"
2249
2213
 
2250
 
    internal_error = True
2251
 
 
2252
2214
    def __init__(self, tree, other_tree, reason):
2253
2215
        self.tree = tree
2254
2216
        self.other_tree = other_tree
2323
2285
 
2324
2286
    _fmt = "Unexpected end of container stream"
2325
2287
 
2326
 
    internal_error = False
2327
 
 
2328
2288
 
2329
2289
class UnknownRecordTypeError(ContainerError):
2330
2290
 
2358
2318
        self.name = name
2359
2319
 
2360
2320
 
2361
 
class NoDestinationAddress(BzrError):
 
2321
class NoDestinationAddress(InternalBzrError):
2362
2322
 
2363
2323
    _fmt = "Message does not have a destination address."
2364
2324
 
2365
 
    internal_error = True
2366
 
 
2367
2325
 
2368
2326
class SMTPError(BzrError):
2369
2327