~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/errors.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-07-22 18:09:04 UTC
  • mfrom: (2485.8.63 bzr.connection.sharing)
  • Revision ID: pqm@pqm.ubuntu.com-20070722180904-wy7y7oyi32wbghgf
Transport connection sharing

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    """
49
49
    Base class for errors raised by bzrlib.
50
50
 
51
 
    :cvar internal_error: if true (or absent) this was probably caused by a
52
 
    bzr bug and should be displayed with a traceback; if False this was
 
51
    :cvar internal_error: if True this was probably caused by a bzr bug and
 
52
    should be displayed with a traceback; if False (or absent) this was
53
53
    probably a user or environment error and they don't need the gory details.
54
54
    (That can be overridden by -Derror on the command line.)
55
55
 
186
186
        self.class_name = class_name
187
187
 
188
188
 
 
189
class IncompatibleAPI(BzrError):
 
190
 
 
191
    _fmt = 'The API for "%(api)s" is not compatible with "%(wanted)s". '\
 
192
        'It supports versions "%(minimum)s" to "%(current)s".'
 
193
 
 
194
    def __init__(self, api, wanted, minimum, current):
 
195
        self.api = api
 
196
        self.wanted = wanted
 
197
        self.minimum = minimum
 
198
        self.current = current
 
199
 
 
200
 
 
201
class InProcessTransport(BzrError):
 
202
 
 
203
    _fmt = "The transport '%(transport)s' is only accessible within this " \
 
204
        "process."
 
205
 
 
206
    def __init__(self, transport):
 
207
        self.transport = transport
 
208
 
 
209
 
189
210
class InvalidEntryName(BzrError):
190
211
    
191
212
    _fmt = "Invalid entry name: %(name)s"
322
343
    _fmt = "Error in command line options"
323
344
 
324
345
 
 
346
class BadIndexFormatSignature(BzrError):
 
347
 
 
348
    _fmt = "%(value)s is not an index of type %(_type)s."
 
349
 
 
350
    def __init__(self, value, _type):
 
351
        BzrError.__init__(self)
 
352
        self.value = value
 
353
        self._type = _type
 
354
 
 
355
 
 
356
class BadIndexData(BzrError):
 
357
 
 
358
    _fmt = "Error in data for index %(value)s."
 
359
 
 
360
    def __init__(self, value):
 
361
        BzrError.__init__(self)
 
362
        self.value = value
 
363
 
 
364
 
 
365
class BadIndexDuplicateKey(BzrError):
 
366
 
 
367
    _fmt = "The key '%(key)s' is already in index '%(index)s'."
 
368
 
 
369
    def __init__(self, key, index):
 
370
        BzrError.__init__(self)
 
371
        self.key = key
 
372
        self.index = index
 
373
 
 
374
 
 
375
class BadIndexKey(BzrError):
 
376
 
 
377
    _fmt = "The key '%(key)s' is not a valid key."
 
378
 
 
379
    def __init__(self, key):
 
380
        BzrError.__init__(self)
 
381
        self.key = key
 
382
 
 
383
 
 
384
class BadIndexOptions(BzrError):
 
385
 
 
386
    _fmt = "Could not parse options for index %(value)s."
 
387
 
 
388
    def __init__(self, value):
 
389
        BzrError.__init__(self)
 
390
        self.value = value
 
391
 
 
392
 
 
393
class BadIndexValue(BzrError):
 
394
 
 
395
    _fmt = "The value '%(value)s' is not a valid value."
 
396
 
 
397
    def __init__(self, value):
 
398
        BzrError.__init__(self)
 
399
        self.value = value
 
400
 
 
401
 
325
402
class BadOptionValue(BzrError):
326
403
 
327
404
    _fmt = """Bad value "%(value)s" for option "%(name)s"."""
337
414
 
338
415
# XXX: Should be unified with TransportError; they seem to represent the
339
416
# same thing
 
417
# RBC 20060929: I think that unifiying with TransportError would be a mistake
 
418
# - this is finer than a TransportError - and more useful as such. It 
 
419
# differentiates between 'transport has failed' and 'operation on a transport
 
420
# has failed.'
340
421
class PathError(BzrError):
341
422
    
342
423
    _fmt = "Generic path error: %(path)r%(extra)s)"
445
526
        PathError.__init__(self, url, extra=extra)
446
527
 
447
528
 
 
529
class ReadError(PathError):
 
530
    
 
531
    _fmt = """Error reading from %(path)r."""
 
532
 
 
533
 
448
534
class ShortReadvError(PathError):
449
535
 
450
536
    _fmt = ("readv() read %(actual)s bytes rather than %(length)s bytes"
459
545
        self.actual = actual
460
546
 
461
547
 
462
 
class PathNotChild(BzrError):
 
548
class PathNotChild(PathError):
463
549
 
464
550
    _fmt = "Path %(path)r is not a child of path %(base)r%(extra)s"
465
551
 
845
931
    _fmt = "No changes to commit"
846
932
 
847
933
 
 
934
class CannotCommitSelectedFileMerge(BzrError):
 
935
 
 
936
    _fmt = 'Selected-file commit of merges is not supported yet:'\
 
937
        ' files %(files_str)s'
 
938
 
 
939
    def __init__(self, files):
 
940
        files_str = ', '.join(files)
 
941
        BzrError.__init__(self, files=files, files_str=files_str)
 
942
 
 
943
 
848
944
class UpgradeReadonly(BzrError):
849
945
 
850
946
    _fmt = "Upgrade URL cannot work with readonly URLs."
1176
1272
        self.file_id = file_id
1177
1273
 
1178
1274
 
 
1275
class VersionedFileInvalidChecksum(VersionedFileError):
 
1276
 
 
1277
    _fmt = "Text did not match its checksum: %(message)s"
 
1278
 
 
1279
 
1179
1280
class KnitError(BzrError):
1180
1281
    
1181
1282
    _fmt = "Knit error"
1524
1625
        self.text_revision = text_revision
1525
1626
        self.file_id = file_id
1526
1627
 
1527
 
 
1528
1628
class DuplicateFileId(BzrError):
1529
1629
 
1530
1630
    _fmt = "File id {%(file_id)s} already exists in inventory as %(entry)s"
1569
1669
 
1570
1670
    _fmt = "Bad parameter: %(param)r"
1571
1671
 
 
1672
    internal_error = True
 
1673
 
1572
1674
    # This exception should never be thrown, but it is a base class for all
1573
1675
    # parameter-to-function errors.
1574
1676
 
2026
2128
        " branch location."
2027
2129
 
2028
2130
 
 
2131
class IllegalMergeDirectivePayload(BzrError):
 
2132
    """A merge directive contained something other than a patch or bundle"""
 
2133
 
 
2134
    _fmt = "Bad merge directive payload %(start)r"
 
2135
 
 
2136
    def __init__(self, start):
 
2137
        BzrError(self)
 
2138
        self.start = start
 
2139
 
 
2140
 
 
2141
class PatchVerificationFailed(BzrError):
 
2142
    """A patch from a merge directive could not be verified"""
 
2143
 
 
2144
    _fmt = "Preview patch does not match requested changes."
 
2145
 
 
2146
 
2029
2147
class PatchMissing(BzrError):
2030
2148
    """Raise a patch type was specified but no patch supplied"""
2031
2149
 
2124
2242
 
2125
2243
    def __init__(self, response_tuple):
2126
2244
        self.response_tuple = response_tuple
 
2245
 
 
2246
 
 
2247
class ContainerError(BzrError):
 
2248
    """Base class of container errors."""
 
2249
 
 
2250
 
 
2251
class UnknownContainerFormatError(ContainerError):
 
2252
 
 
2253
    _fmt = "Unrecognised container format: %(container_format)r"
 
2254
    
 
2255
    def __init__(self, container_format):
 
2256
        self.container_format = container_format
 
2257
 
 
2258
 
 
2259
class UnexpectedEndOfContainerError(ContainerError):
 
2260
 
 
2261
    _fmt = "Unexpected end of container stream"
 
2262
 
 
2263
    internal_error = False
 
2264
 
 
2265
 
 
2266
class UnknownRecordTypeError(ContainerError):
 
2267
 
 
2268
    _fmt = "Unknown record type: %(record_type)r"
 
2269
 
 
2270
    def __init__(self, record_type):
 
2271
        self.record_type = record_type
 
2272
 
 
2273
 
 
2274
class InvalidRecordError(ContainerError):
 
2275
 
 
2276
    _fmt = "Invalid record: %(reason)s"
 
2277
 
 
2278
    def __init__(self, reason):
 
2279
        self.reason = reason
 
2280
 
 
2281
 
 
2282
class ContainerHasExcessDataError(ContainerError):
 
2283
 
 
2284
    _fmt = "Container has data after end marker: %(excess)r"
 
2285
 
 
2286
    def __init__(self, excess):
 
2287
        self.excess = excess
 
2288
 
 
2289
 
 
2290
class DuplicateRecordNameError(ContainerError):
 
2291
 
 
2292
    _fmt = "Container has multiple records with the same name: \"%(name)s\""
 
2293
 
 
2294
    def __init__(self, name):
 
2295
        self.name = name
 
2296
 
 
2297
 
 
2298
class NoDestinationAddress(BzrError):
 
2299
 
 
2300
    _fmt = "Message does not have a destination address."
 
2301
 
 
2302
    internal_error = True
 
2303
 
 
2304
 
 
2305
class SMTPError(BzrError):
 
2306
 
 
2307
    _fmt = "SMTP error: %(error)s"
 
2308
 
 
2309
    def __init__(self, error):
 
2310
        self.error = error