120
120
# base classes should override the docstring with their human-
121
121
# readable explanation
123
def __init__(self, **kwds):
123
def __init__(self, *args, **kwds):
124
# XXX: Use the underlying BzrError to always generate the args attribute
125
# if it doesn't exist. We can't use super here, because exceptions are
126
# old-style classes in python2.4 (but new in 2.5). --bmc, 20060426
127
BzrError.__init__(self, *args)
124
128
for key, value in kwds.items():
125
129
setattr(self, key, value)
127
131
def __str__(self):
129
return self.__doc__ % self.__dict__
130
except (NameError, ValueError, KeyError), e:
131
return 'Unprintable exception %s: %s' \
132
% (self.__class__.__name__, str(e))
133
# __str__() should always return a 'str' object
134
# never a 'unicode' object.
135
s = self.__doc__ % self.__dict__
136
if isinstance(s, unicode):
137
return s.encode('utf8')
139
except (TypeError, NameError, ValueError, KeyError), e:
140
return 'Unprintable exception %s(%r): %s' \
141
% (self.__class__.__name__,
142
self.__dict__, str(e))
145
class AlreadyBuilding(BzrNewError):
146
"""The tree builder is already building a tree."""
135
149
class BzrCheckError(BzrNewError):
168
183
self.branch = branch
186
class InventoryModified(BzrNewError):
187
"""The current inventory for the tree %(tree)r has been modified, so a clean inventory cannot be read without data loss."""
189
def __init__(self, tree):
190
BzrNewError.__init__(self)
194
class NoSuchId(BzrNewError):
195
"""The file id %(file_id)s is not present in the tree %(tree)s."""
197
def __init__(self, tree, file_id):
198
BzrNewError.__init__(self)
199
self.file_id = file_id
171
203
class NoWorkingTree(BzrNewError):
172
204
"""No WorkingTree exists for %(base)s."""
223
class NotWriteLocked(BzrNewError):
224
"""%(not_locked)r is not write locked but needs to be."""
226
def __init__(self, not_locked):
227
BzrNewError.__init__(self)
228
self.not_locked = not_locked
187
231
class BzrCommandError(BzrNewError):
188
232
"""Error from user command"""
197
241
# BzrCommandError, and non-UI code should not throw a subclass of
198
242
# BzrCommandError. ADHB 20051211
199
243
def __init__(self, msg):
244
# Object.__str__() must return a real string
245
# returning a Unicode string is a python error.
246
if isinstance(msg, unicode):
247
self.msg = msg.encode('utf8')
202
251
def __str__(self):
237
286
"""Directory not empty: %(path)r%(extra)s"""
289
class ReadingCompleted(BzrNewError):
290
"""The MediumRequest '%(request)s' has already had finish_reading called upon it - the request has been completed and no more data may be read."""
292
is_user_error = False
294
def __init__(self, request):
295
BzrNewError.__init__(self)
296
self.request = request
240
299
class ResourceBusy(PathError):
241
300
"""Device or resource busy: %(path)r%(extra)s"""
265
323
PathError.__init__(self, url, extra=extra)
326
class ShortReadvError(PathError):
327
"""readv() read %(actual)s bytes rather than %(length)s bytes at %(offset)s for %(path)s%(extra)s"""
329
is_user_error = False
331
def __init__(self, path, offset, length, actual, extra=None):
332
PathError.__init__(self, path, extra=extra)
268
338
class PathNotChild(BzrNewError):
269
339
"""Path %(path)r is not a child of path %(base)r%(extra)s"""
354
424
self.bzrdir = bzrdir_format
427
class IncompatibleRevision(BzrNewError):
428
"""Revision is not compatible with %(repo_format)s"""
430
def __init__(self, repo_format):
431
BzrNewError.__init__(self)
432
self.repo_format = repo_format
357
435
class NotVersionedError(BzrNewError):
358
436
"""%(path)s is not versioned"""
359
437
def __init__(self, path):
505
582
is_user_error = False
507
584
def __init__(self, branch, revision):
509
self.revision = revision
585
BzrNewError.__init__(self, branch=branch, revision=revision)
588
class NoSuchRevisionSpec(BzrNewError):
589
"""No namespace registered for string: %(spec)r"""
591
def __init__(self, spec):
592
BzrNewError.__init__(self, spec=spec)
595
class InvalidRevisionSpec(BzrNewError):
596
"""Requested revision: '%(spec)s' does not exist in branch:
597
%(branch)s%(extra)s"""
599
def __init__(self, spec, branch, extra=None):
600
BzrNewError.__init__(self, branch=branch, spec=spec)
602
self.extra = '\n' + str(extra)
512
607
class HistoryMissing(BzrError):
575
670
self.bases = bases
578
class NoCommits(BzrError):
673
class NoCommits(BzrNewError):
674
"""Branch %(branch)s has no commits."""
579
676
def __init__(self, branch):
580
msg = "Branch %s has no commits." % branch
581
BzrError.__init__(self, msg)
677
BzrNewError.__init__(self, branch=branch)
584
680
class UnlistableStore(BzrError):
733
829
class NoSuchExportFormat(BzrNewError):
734
830
"""Export format %(format)r not supported"""
735
832
def __init__(self, format):
736
833
BzrNewError.__init__(self)
737
834
self.format = format
838
class TooManyConcurrentRequests(BzrNewError):
839
"""The medium '%(medium)s' has reached its concurrent request limit. Be sure to finish_writing and finish_reading on the current request that is open."""
841
def __init__(self, medium):
842
BzrNewError.__init__(self)
740
846
class TransportError(BzrNewError):
741
847
"""Transport error: %(msg)s %(orig_error)s"""
752
858
BzrNewError.__init__(self)
861
class SmartProtocolError(TransportError):
862
"""Generic bzr smart protocol error: %(details)s"""
864
def __init__(self, details):
865
self.details = details
755
868
# A set of semi-meaningful errors which can be thrown
756
869
class TransportNotPossible(TransportError):
757
"""Transport operation not possible: %(msg)s %(orig_error)%"""
870
"""Transport operation not possible: %(msg)s %(orig_error)s"""
760
873
class ConnectionError(TransportError):
768
881
class InvalidRange(TransportError):
769
"""Invalid range access."""
882
"""Invalid range access in %(path)s at %(offset)s."""
771
884
def __init__(self, path, offset):
772
885
TransportError.__init__(self, ("Invalid range access in %s at %d"
773
886
% (path, offset)))
776
891
class InvalidHttpResponse(TransportError):
811
926
BzrError.__init__(self, message)
929
class NoEmailInUsername(BzrNewError):
930
"""%(username)r does not seem to contain a reasonable email address"""
932
def __init__(self, username):
933
BzrNewError.__init__(self)
934
self.username = username
814
937
class SigningFailed(BzrError):
815
938
def __init__(self, command_line):
816
939
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
824
947
" unchanged." % tree.basedir)
950
class WritingCompleted(BzrNewError):
951
"""The MediumRequest '%(request)s' has already had finish_writing called upon it - accept bytes may not be called anymore."""
953
is_user_error = False
955
def __init__(self, request):
956
BzrNewError.__init__(self)
957
self.request = request
960
class WritingNotComplete(BzrNewError):
961
"""The MediumRequest '%(request)s' has not has finish_writing called upon it - until the write phase is complete no data may be read."""
963
is_user_error = False
965
def __init__(self, request):
966
BzrNewError.__init__(self)
967
self.request = request
827
970
class CantReprocessAndShowBase(BzrNewError):
828
971
"""Can't reprocess and show base.
829
972
Reprocessing obscures relationship of conflicting lines to base."""
885
1036
"""Tree transform is malformed %(conflicts)r"""
1039
class NoFinalPath(BzrNewError):
1040
"""No final name for trans_id %(trans_id)r
1041
file-id: %(file_id)r"
1042
root trans-id: %(root_trans_id)r
1045
def __init__(self, trans_id, transform):
1046
self.trans_id = trans_id
1047
self.file_id = transform.final_file_id(trans_id)
1048
self.root_trans_id = transform.root
888
1051
class BzrBadParameter(BzrNewError):
889
1052
"""A bad parameter : %(param)s is not usable.
946
1113
self.format = format
1116
class BadConversionTarget(BzrNewError):
1117
"""Cannot convert to format %(format)s. %(problem)s"""
1119
def __init__(self, problem, format):
1120
BzrNewError.__init__(self)
1121
self.problem = problem
1122
self.format = format
949
1125
class NoDiff(BzrNewError):
950
1126
"""Diff is not installed on this machine: %(msg)s"""
1096
1272
BzrNewError.__init__(self)
1097
1273
self.text = text
1099
1276
class UnsupportedEOLMarker(BadBundle):
1100
1277
"""End of line marker was not \\n in bzr revision-bundle"""
1102
1279
def __init__(self):
1103
BzrNewError.__init__(self)
1280
BzrNewError.__init__(self)
1283
class IncompatibleFormat(BzrNewError):
1284
"""Bundle format %(bundle_format)s is incompatible with %(other)s"""
1286
def __init__(self, bundle_format, other):
1287
BzrNewError.__init__(self)
1288
self.bundle_format = bundle_format
1292
class BadInventoryFormat(BzrNewError):
1293
"""Root class for inventory serialization errors"""
1296
class UnexpectedInventoryFormat(BadInventoryFormat):
1297
"""The inventory was not in the expected format:\n %(msg)s"""
1299
def __init__(self, msg):
1300
BadInventoryFormat.__init__(self, msg=msg)
1303
class NoSmartMedium(BzrNewError):
1304
"""The transport '%(transport)s' cannot tunnel the smart protocol."""
1306
def __init__(self, transport):
1307
BzrNewError.__init__(self)
1308
self.transport = transport
1311
class NoSmartServer(NotBranchError):
1312
"""No smart server available at %(url)s"""
1314
def __init__(self, url):
1318
class UnknownSSH(BzrNewError):
1319
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1321
def __init__(self, vendor):
1322
BzrNewError.__init__(self)
1323
self.vendor = vendor
1326
class GhostRevisionUnusableHere(BzrNewError):
1327
"""Ghost revision {%(revision_id)s} cannot be used here."""
1329
def __init__(self, revision_id):
1330
BzrNewError.__init__(self)
1331
self.revision_id = revision_id
1334
class IllegalUseOfScopeReplacer(BzrNewError):
1335
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1337
is_user_error = False
1339
def __init__(self, name, msg, extra=None):
1340
BzrNewError.__init__(self)
1344
self.extra = ': ' + str(extra)
1349
class InvalidImportLine(BzrNewError):
1350
"""Not a valid import statement: %(msg)\n%(text)s"""
1352
is_user_error = False
1354
def __init__(self, text, msg):
1355
BzrNewError.__init__(self)
1360
class ImportNameCollision(BzrNewError):
1361
"""Tried to import an object to the same name as an existing object. %(name)s"""
1363
is_user_error = False
1365
def __init__(self, name):
1366
BzrNewError.__init__(self)