85
34
# constructed to make sure it will succeed. But that says nothing about
86
35
# exceptions that are never raised.
88
# TODO: Convert all the other error classes here to BzrNewError, and eliminate
91
# TODO: The pattern (from hct) of using classes docstrings as message
92
# templates is cute but maybe not such a great idea - perhaps should have a
93
# separate static message_template.
37
# TODO: selftest assertRaises should probably also check that every error
38
# raised can be formatted as a string successfully, and without giving
96
42
class BzrError(StandardError):
44
Base class for errors raised by bzrlib.
46
:cvar internal_error: if true (or absent) this was probably caused by a
47
bzr bug and should be displayed with a traceback; if False this was
48
probably a user or environment error and they don't need the gory details.
49
(That can be overridden by -Derror on the command line.)
51
:cvar _fmt: Format string to display the error; this is expanded
52
by the instance's dict.
55
internal_error = False
57
def __init__(self, msg=None, **kwds):
58
"""Construct a new BzrError.
60
There are two alternative forms for constructing these objects.
61
Either a preformatted string may be passed, or a set of named
62
arguments can be given. The first is for generic "user" errors which
63
are not intended to be caught and so do not need a specific subclass.
64
The second case is for use with subclasses that provide a _fmt format
65
string to print the arguments.
67
Keyword arguments are taken as parameters to the error, which can
68
be inserted into the format string template. It's recommended
69
that subclasses override the __init__ method to require specific
72
:param msg: If given, this is the literal complete text for the error,
73
not subject to expansion.
75
StandardError.__init__(self)
77
# I was going to deprecate this, but it actually turns out to be
78
# quite handy - mbp 20061103.
79
self._preformatted_string = msg
81
self._preformatted_string = None
82
for key, value in kwds.items():
83
setattr(self, key, value)
100
85
def __str__(self):
101
# XXX: Should we show the exception class in
102
# exceptions that don't provide their own message?
103
# maybe it should be done at a higher level
104
## n = self.__class__.__name__ + ': '
106
if len(self.args) == 1:
107
return str(self.args[0])
108
elif len(self.args) == 2:
109
# further explanation or suggestions
111
return n + '\n '.join([self.args[0]] + self.args[1])
113
return n + "%r" % self
115
return n + `self.args`
86
s = getattr(self, '_preformatted_string', None)
88
# contains a preformatted message; must be cast to plain str
91
fmt = self._get_format_string()
93
s = fmt % self.__dict__
94
# __str__() should always return a 'str' object
95
# never a 'unicode' object.
96
if isinstance(s, unicode):
97
return s.encode('utf8')
99
except (AttributeError, TypeError, NameError, ValueError, KeyError), e:
100
return 'Unprintable exception %s: dict=%r, fmt=%r, error=%s' \
101
% (self.__class__.__name__,
103
getattr(self, '_fmt', None),
106
def _get_format_string(self):
107
"""Return format string for this exception or None"""
108
fmt = getattr(self, '_fmt', None)
111
fmt = getattr(self, '__doc__', None)
113
symbol_versioning.warn("%s uses its docstring as a format, "
114
"it should use _fmt instead" % self.__class__.__name__,
117
return 'Unprintable exception %s: dict=%r, fmt=%r' \
118
% (self.__class__.__name__,
120
getattr(self, '_fmt', None),
118
124
class BzrNewError(BzrError):
125
"""Deprecated error base class."""
120
126
# base classes should override the docstring with their human-
121
127
# readable explanation
142
153
self.__dict__, str(e))
145
class AlreadyBuilding(BzrNewError):
146
"""The tree builder is already building a tree."""
149
class BzrCheckError(BzrNewError):
150
"""Internal check failed: %(message)s"""
152
is_user_error = False
156
class AlreadyBuilding(BzrError):
158
_fmt = "The tree builder is already building a tree."
161
class BzrCheckError(BzrError):
163
_fmt = "Internal check failed: %(message)s"
165
internal_error = True
154
167
def __init__(self, message):
155
BzrNewError.__init__(self)
168
BzrError.__init__(self)
156
169
self.message = message
159
class InvalidEntryName(BzrNewError):
160
"""Invalid entry name: %(name)s"""
172
class InvalidEntryName(BzrError):
174
_fmt = "Invalid entry name: %(name)s"
162
is_user_error = False
176
internal_error = True
164
178
def __init__(self, name):
165
BzrNewError.__init__(self)
179
BzrError.__init__(self)
169
class InvalidRevisionNumber(BzrNewError):
170
"""Invalid revision number %(revno)d"""
183
class InvalidRevisionNumber(BzrError):
185
_fmt = "Invalid revision number %(revno)s"
171
187
def __init__(self, revno):
172
BzrNewError.__init__(self)
188
BzrError.__init__(self)
173
189
self.revno = revno
176
class InvalidRevisionId(BzrNewError):
177
"""Invalid revision-id {%(revision_id)s} in %(branch)s"""
192
class InvalidRevisionId(BzrError):
194
_fmt = "Invalid revision-id {%(revision_id)s} in %(branch)s"
179
196
def __init__(self, revision_id, branch):
180
197
# branch can be any string or object with __str__ defined
181
BzrNewError.__init__(self)
198
BzrError.__init__(self)
182
199
self.revision_id = revision_id
183
200
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."""
202
class ReservedId(BzrError):
204
_fmt = "Reserved revision-id {%(revision_id)s}"
206
def __init__(self, revision_id):
207
self.revision_id = revision_id
209
class NoSuchId(BzrError):
211
_fmt = "The file id %(file_id)s is not present in the tree %(tree)s."
197
213
def __init__(self, tree, file_id):
198
BzrNewError.__init__(self)
214
BzrError.__init__(self)
199
215
self.file_id = file_id
203
class NoWorkingTree(BzrNewError):
204
"""No WorkingTree exists for %(base)s."""
219
class InventoryModified(BzrError):
221
_fmt = ("The current inventory for the tree %(tree)r has been modified, "
222
"so a clean inventory cannot be read without data loss.")
224
internal_error = True
226
def __init__(self, tree):
230
class NoWorkingTree(BzrError):
232
_fmt = "No WorkingTree exists for %(base)s."
206
234
def __init__(self, base):
207
BzrNewError.__init__(self)
235
BzrError.__init__(self)
211
class NotBuilding(BzrNewError):
212
"""Not currently building a tree."""
215
class NotLocalUrl(BzrNewError):
216
"""%(url)s is not a local path."""
239
class NotBuilding(BzrError):
241
_fmt = "Not currently building a tree."
244
class NotLocalUrl(BzrError):
246
_fmt = "%(url)s is not a local path."
218
248
def __init__(self, url):
219
BzrNewError.__init__(self)
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
231
class BzrCommandError(BzrNewError):
252
class WorkingTreeAlreadyPopulated(BzrError):
254
_fmt = """Working tree already populated in %(base)s"""
256
internal_error = True
258
def __init__(self, base):
261
class BzrCommandError(BzrError):
232
262
"""Error from user command"""
264
internal_error = False
236
266
# Error from malformed user command; please avoid raising this as a
237
267
# generic exception not caused by user input.
915
1134
BzrError.__init__(self, message)
918
class NoEmailInUsername(BzrNewError):
919
"""%(username)r does not seem to contain a reasonable email address"""
1137
class NoEmailInUsername(BzrError):
1139
_fmt = "%(username)r does not seem to contain a reasonable email address"
921
1141
def __init__(self, username):
922
BzrNewError.__init__(self)
1142
BzrError.__init__(self)
923
1143
self.username = username
926
1146
class SigningFailed(BzrError):
1148
_fmt = "Failed to gpg sign data with command %(command_line)r"
927
1150
def __init__(self, command_line):
928
BzrError.__init__(self, "Failed to gpg sign data with command '%s'"
1151
BzrError.__init__(self, command_line=command_line)
932
1154
class WorkingTreeNotRevision(BzrError):
1156
_fmt = ("The working tree for %(basedir)s has changed since"
1157
" the last commit, but weave merge requires that it be"
933
1160
def __init__(self, tree):
934
BzrError.__init__(self, "The working tree for %s has changed since"
935
" last commit, but weave merge requires that it be"
936
" unchanged." % tree.basedir)
939
class CantReprocessAndShowBase(BzrNewError):
940
"""Can't reprocess and show base.
941
Reprocessing obscures relationship of conflicting lines to base."""
944
class GraphCycleError(BzrNewError):
945
"""Cycle in graph %(graph)r"""
1161
BzrError.__init__(self, basedir=tree.basedir)
1164
class CantReprocessAndShowBase(BzrError):
1166
_fmt = "Can't reprocess and show base, because reprocessing obscures " \
1167
"the relationship of conflicting lines to the base"
1170
class GraphCycleError(BzrError):
1172
_fmt = "Cycle in graph %(graph)r"
946
1174
def __init__(self, graph):
947
BzrNewError.__init__(self)
1175
BzrError.__init__(self)
948
1176
self.graph = graph
951
class NotConflicted(BzrNewError):
952
"""File %(filename)s is not conflicted."""
1179
class WritingCompleted(BzrError):
1181
_fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
1182
"called upon it - accept bytes may not be called anymore.")
1184
internal_error = True
1186
def __init__(self, request):
1187
self.request = request
1190
class WritingNotComplete(BzrError):
1192
_fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
1193
"called upon it - until the write phase is complete no "
1194
"data may be read.")
1196
internal_error = True
1198
def __init__(self, request):
1199
self.request = request
1202
class NotConflicted(BzrError):
1204
_fmt = "File %(filename)s is not conflicted."
954
1206
def __init__(self, filename):
955
BzrNewError.__init__(self)
1207
BzrError.__init__(self)
956
1208
self.filename = filename
1211
class MediumNotConnected(BzrError):
1213
_fmt = """The medium '%(medium)s' is not connected."""
1215
internal_error = True
1217
def __init__(self, medium):
1218
self.medium = medium
959
1221
class MustUseDecorated(Exception):
960
"""A decorating function has requested its original command be used.
962
This should never escape bzr, so does not need to be printable.
966
class NoBundleFound(BzrNewError):
967
"""No bundle was found in %(filename)s"""
1223
_fmt = """A decorating function has requested its original command be used."""
1226
class NoBundleFound(BzrError):
1228
_fmt = "No bundle was found in %(filename)s"
968
1230
def __init__(self, filename):
969
BzrNewError.__init__(self)
1231
BzrError.__init__(self)
970
1232
self.filename = filename
973
class BundleNotSupported(BzrNewError):
974
"""Unable to handle bundle version %(version)s: %(msg)s"""
1235
class BundleNotSupported(BzrError):
1237
_fmt = "Unable to handle bundle version %(version)s: %(msg)s"
975
1239
def __init__(self, version, msg):
976
BzrNewError.__init__(self)
1240
BzrError.__init__(self)
977
1241
self.version = version
981
class MissingText(BzrNewError):
982
"""Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"""
1245
class MissingText(BzrError):
1247
_fmt = "Branch %(base)s is missing revision %(text_revision)s of %(file_id)s"
984
1249
def __init__(self, branch, text_revision, file_id):
985
BzrNewError.__init__(self)
1250
BzrError.__init__(self)
986
1251
self.branch = branch
987
1252
self.base = branch.base
988
1253
self.text_revision = text_revision
989
1254
self.file_id = file_id
992
class DuplicateKey(BzrNewError):
993
"""Key %(key)s is already present in map"""
996
class MalformedTransform(BzrNewError):
997
"""Tree transform is malformed %(conflicts)r"""
1000
class BzrBadParameter(BzrNewError):
1001
"""A bad parameter : %(param)s is not usable.
1003
This exception should never be thrown, but it is a base class for all
1004
parameter-to-function errors.
1257
class DuplicateKey(BzrError):
1259
_fmt = "Key %(key)s is already present in map"
1262
class MalformedTransform(BzrError):
1264
_fmt = "Tree transform is malformed %(conflicts)r"
1267
class NoFinalPath(BzrError):
1269
_fmt = ("No final name for trans_id %(trans_id)r\n"
1270
"file-id: %(file_id)r\n"
1271
"root trans-id: %(root_trans_id)r\n")
1273
def __init__(self, trans_id, transform):
1274
self.trans_id = trans_id
1275
self.file_id = transform.final_file_id(trans_id)
1276
self.root_trans_id = transform.root
1279
class BzrBadParameter(BzrError):
1281
_fmt = "Bad parameter: %(param)r"
1283
# This exception should never be thrown, but it is a base class for all
1284
# parameter-to-function errors.
1006
1286
def __init__(self, param):
1007
BzrNewError.__init__(self)
1287
BzrError.__init__(self)
1008
1288
self.param = param
1011
1291
class BzrBadParameterNotUnicode(BzrBadParameter):
1012
"""Parameter %(param)s is neither unicode nor utf8."""
1015
class ReusingTransform(BzrNewError):
1016
"""Attempt to reuse a transform that has already been applied."""
1019
class CantMoveRoot(BzrNewError):
1020
"""Moving the root directory is not supported at this time"""
1293
_fmt = "Parameter %(param)s is neither unicode nor utf8."
1296
class ReusingTransform(BzrError):
1298
_fmt = "Attempt to reuse a transform that has already been applied."
1301
class CantMoveRoot(BzrError):
1303
_fmt = "Moving the root directory is not supported at this time"
1023
1306
class BzrBadParameterNotString(BzrBadParameter):
1024
"""Parameter %(param)s is not a string or unicode string."""
1308
_fmt = "Parameter %(param)s is not a string or unicode string."
1027
1311
class BzrBadParameterMissing(BzrBadParameter):
1028
"""Parameter $(param)s is required but not present."""
1313
_fmt = "Parameter $(param)s is required but not present."
1031
1316
class BzrBadParameterUnicode(BzrBadParameter):
1032
"""Parameter %(param)s is unicode but only byte-strings are permitted."""
1318
_fmt = "Parameter %(param)s is unicode but only byte-strings are permitted."
1035
1321
class BzrBadParameterContainsNewline(BzrBadParameter):
1036
"""Parameter %(param)s contains a newline."""
1039
class DependencyNotPresent(BzrNewError):
1040
"""Unable to import library "%(library)s": %(error)s"""
1323
_fmt = "Parameter %(param)s contains a newline."
1326
class DependencyNotPresent(BzrError):
1328
_fmt = 'Unable to import library "%(library)s": %(error)s'
1042
1330
def __init__(self, library, error):
1043
BzrNewError.__init__(self, library=library, error=error)
1331
BzrError.__init__(self, library=library, error=error)
1046
1334
class ParamikoNotPresent(DependencyNotPresent):
1047
"""Unable to import paramiko (required for sftp support): %(error)s"""
1336
_fmt = "Unable to import paramiko (required for sftp support): %(error)s"
1049
1338
def __init__(self, error):
1050
1339
DependencyNotPresent.__init__(self, 'paramiko', error)
1053
class PointlessMerge(BzrNewError):
1054
"""Nothing to merge."""
1057
class UninitializableFormat(BzrNewError):
1058
"""Format %(format)s cannot be initialised by this version of bzr."""
1342
class PointlessMerge(BzrError):
1344
_fmt = "Nothing to merge."
1347
class UninitializableFormat(BzrError):
1349
_fmt = "Format %(format)s cannot be initialised by this version of bzr."
1060
1351
def __init__(self, format):
1061
BzrNewError.__init__(self)
1352
BzrError.__init__(self)
1062
1353
self.format = format
1065
class BadConversionTarget(BzrNewError):
1066
"""Cannot convert to format %(format)s. %(problem)s"""
1356
class BadConversionTarget(BzrError):
1358
_fmt = "Cannot convert to format %(format)s. %(problem)s"
1068
1360
def __init__(self, problem, format):
1069
BzrNewError.__init__(self)
1361
BzrError.__init__(self)
1070
1362
self.problem = problem
1071
1363
self.format = format
1074
class NoDiff(BzrNewError):
1075
"""Diff is not installed on this machine: %(msg)s"""
1366
class NoDiff(BzrError):
1368
_fmt = "Diff is not installed on this machine: %(msg)s"
1077
1370
def __init__(self, msg):
1078
BzrNewError.__init__(self, msg=msg)
1081
class NoDiff3(BzrNewError):
1082
"""Diff3 is not installed on this machine."""
1085
class ExistingLimbo(BzrNewError):
1086
"""This tree contains left-over files from a failed operation.
1087
Please examine %(limbo_dir)s to see if it contains any files you wish to
1088
keep, and delete it when you are done.
1090
def __init__(self, limbo_dir):
1091
BzrNewError.__init__(self)
1092
self.limbo_dir = limbo_dir
1095
class ImmortalLimbo(BzrNewError):
1096
"""Unable to delete transform temporary directory $(limbo_dir)s.
1097
Please examine %(limbo_dir)s to see if it contains any files you wish to
1098
keep, and delete it when you are done.
1100
def __init__(self, limbo_dir):
1101
BzrNewError.__init__(self)
1102
self.limbo_dir = limbo_dir
1105
class OutOfDateTree(BzrNewError):
1106
"""Working tree is out of date, please run 'bzr update'."""
1371
BzrError.__init__(self, msg=msg)
1374
class NoDiff3(BzrError):
1376
_fmt = "Diff3 is not installed on this machine."
1379
class ExistingLimbo(BzrError):
1381
_fmt = """This tree contains left-over files from a failed operation.
1382
Please examine %(limbo_dir)s to see if it contains any files you wish to
1383
keep, and delete it when you are done."""
1385
def __init__(self, limbo_dir):
1386
BzrError.__init__(self)
1387
self.limbo_dir = limbo_dir
1390
class ImmortalLimbo(BzrError):
1392
_fmt = """Unable to delete transform temporary directory $(limbo_dir)s.
1393
Please examine %(limbo_dir)s to see if it contains any files you wish to
1394
keep, and delete it when you are done."""
1396
def __init__(self, limbo_dir):
1397
BzrError.__init__(self)
1398
self.limbo_dir = limbo_dir
1401
class OutOfDateTree(BzrError):
1403
_fmt = "Working tree is out of date, please run 'bzr update'."
1108
1405
def __init__(self, tree):
1109
BzrNewError.__init__(self)
1406
BzrError.__init__(self)
1110
1407
self.tree = tree
1113
class MergeModifiedFormatError(BzrNewError):
1114
"""Error in merge modified format"""
1117
class ConflictFormatError(BzrNewError):
1118
"""Format error in conflict listings"""
1121
class CorruptRepository(BzrNewError):
1122
"""An error has been detected in the repository %(repo_path)s.
1410
class MergeModifiedFormatError(BzrError):
1412
_fmt = "Error in merge modified format"
1415
class ConflictFormatError(BzrError):
1417
_fmt = "Format error in conflict listings"
1420
class CorruptRepository(BzrError):
1422
_fmt = """An error has been detected in the repository %(repo_path)s.
1123
1423
Please run bzr reconcile on this repository."""
1125
1425
def __init__(self, repo):
1126
BzrNewError.__init__(self)
1426
BzrError.__init__(self)
1127
1427
self.repo_path = repo.bzrdir.root_transport.base
1130
class UpgradeRequired(BzrNewError):
1131
"""To use this feature you must upgrade your branch at %(path)s."""
1430
class UpgradeRequired(BzrError):
1432
_fmt = "To use this feature you must upgrade your branch at %(path)s."
1133
1434
def __init__(self, path):
1134
BzrNewError.__init__(self)
1435
BzrError.__init__(self)
1135
1436
self.path = path
1138
class LocalRequiresBoundBranch(BzrNewError):
1139
"""Cannot perform local-only commits on unbound branches."""
1142
class MissingProgressBarFinish(BzrNewError):
1143
"""A nested progress bar was not 'finished' correctly."""
1146
class InvalidProgressBarType(BzrNewError):
1147
"""Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1439
class LocalRequiresBoundBranch(BzrError):
1441
_fmt = "Cannot perform local-only commits on unbound branches."
1444
class MissingProgressBarFinish(BzrError):
1446
_fmt = "A nested progress bar was not 'finished' correctly."
1449
class InvalidProgressBarType(BzrError):
1451
_fmt = """Environment variable BZR_PROGRESS_BAR='%(bar_type)s is not a supported type
1148
1452
Select one of: %(valid_types)s"""
1150
1454
def __init__(self, bar_type, valid_types):
1151
BzrNewError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1154
class UnsupportedOperation(BzrNewError):
1155
"""The method %(mname)s is not supported on objects of type %(tname)s."""
1455
BzrError.__init__(self, bar_type=bar_type, valid_types=valid_types)
1458
class UnsupportedOperation(BzrError):
1460
_fmt = "The method %(mname)s is not supported on objects of type %(tname)s."
1156
1462
def __init__(self, method, method_self):
1157
1463
self.method = method
1158
1464
self.mname = method.__name__
1159
1465
self.tname = type(method_self).__name__
1162
class BinaryFile(BzrNewError):
1163
"""File is binary but should be text."""
1166
class IllegalPath(BzrNewError):
1167
"""The path %(path)s is not permitted on this platform"""
1468
class CannotSetRevisionId(UnsupportedOperation):
1469
"""Raised when a commit is attempting to set a revision id but cant."""
1472
class NonAsciiRevisionId(UnsupportedOperation):
1473
"""Raised when a commit is attempting to set a non-ascii revision id but cant."""
1476
class BinaryFile(BzrError):
1478
_fmt = "File is binary but should be text."
1481
class IllegalPath(BzrError):
1483
_fmt = "The path %(path)s is not permitted on this platform"
1169
1485
def __init__(self, path):
1170
BzrNewError.__init__(self)
1486
BzrError.__init__(self)
1171
1487
self.path = path
1174
class TestamentMismatch(BzrNewError):
1175
"""Testament did not match expected value.
1490
class TestamentMismatch(BzrError):
1492
_fmt = """Testament did not match expected value.
1176
1493
For revision_id {%(revision_id)s}, expected {%(expected)s}, measured
1179
1496
def __init__(self, revision_id, expected, measured):
1180
1497
self.revision_id = revision_id
1181
1498
self.expected = expected
1182
1499
self.measured = measured
1185
class NotABundle(BzrNewError):
1186
"""Not a bzr revision-bundle: %(text)r"""
1502
class NotABundle(BzrError):
1504
_fmt = "Not a bzr revision-bundle: %(text)r"
1188
1506
def __init__(self, text):
1189
BzrNewError.__init__(self)
1507
BzrError.__init__(self)
1190
1508
self.text = text
1193
class BadBundle(BzrNewError):
1194
"""Bad bzr revision-bundle: %(text)r"""
1511
class BadBundle(BzrError):
1513
_fmt = "Bad bzr revision-bundle: %(text)r"
1196
1515
def __init__(self, text):
1197
BzrNewError.__init__(self)
1516
BzrError.__init__(self)
1198
1517
self.text = text
1201
1520
class MalformedHeader(BadBundle):
1202
"""Malformed bzr revision-bundle header: %(text)r"""
1204
def __init__(self, text):
1205
BzrNewError.__init__(self)
1522
_fmt = "Malformed bzr revision-bundle header: %(text)r"
1209
1525
class MalformedPatches(BadBundle):
1210
"""Malformed patches in bzr revision-bundle: %(text)r"""
1212
def __init__(self, text):
1213
BzrNewError.__init__(self)
1527
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
1217
1530
class MalformedFooter(BadBundle):
1218
"""Malformed footer in bzr revision-bundle: %(text)r"""
1220
def __init__(self, text):
1221
BzrNewError.__init__(self)
1532
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
1225
1535
class UnsupportedEOLMarker(BadBundle):
1226
"""End of line marker was not \\n in bzr revision-bundle"""
1537
_fmt = "End of line marker was not \\n in bzr revision-bundle"
1228
1539
def __init__(self):
1229
BzrNewError.__init__(self)
1232
class IncompatibleFormat(BzrNewError):
1233
"""Bundle format %(bundle_format)s is incompatible with %(other)s"""
1540
# XXX: BadBundle's constructor assumes there's explanatory text,
1541
# but for this there is not
1542
BzrError.__init__(self)
1545
class IncompatibleBundleFormat(BzrError):
1547
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
1235
1549
def __init__(self, bundle_format, other):
1236
BzrNewError.__init__(self)
1550
BzrError.__init__(self)
1237
1551
self.bundle_format = bundle_format
1238
1552
self.other = other
1241
class BadInventoryFormat(BzrNewError):
1242
"""Root class for inventory serialization errors"""
1555
class BadInventoryFormat(BzrError):
1557
_fmt = "Root class for inventory serialization errors"
1245
1560
class UnexpectedInventoryFormat(BadInventoryFormat):
1246
"""The inventory was not in the expected format:\n %(msg)s"""
1562
_fmt = "The inventory was not in the expected format:\n %(msg)s"
1248
1564
def __init__(self, msg):
1249
1565
BadInventoryFormat.__init__(self, msg=msg)
1568
class NoSmartMedium(BzrError):
1570
_fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
1572
def __init__(self, transport):
1573
self.transport = transport
1252
1576
class NoSmartServer(NotBranchError):
1253
"""No smart server available at %(url)s"""
1578
_fmt = "No smart server available at %(url)s"
1255
1580
def __init__(self, url):
1259
class UnknownSSH(BzrNewError):
1260
"""Unrecognised value for BZR_SSH environment variable: %(vendor)s"""
1584
class UnknownSSH(BzrError):
1586
_fmt = "Unrecognised value for BZR_SSH environment variable: %(vendor)s"
1262
1588
def __init__(self, vendor):
1263
BzrNewError.__init__(self)
1589
BzrError.__init__(self)
1264
1590
self.vendor = vendor
1267
class GhostRevisionUnusableHere(BzrNewError):
1268
"""Ghost revision {%(revision_id)s} cannot be used here."""
1593
class GhostRevisionUnusableHere(BzrError):
1595
_fmt = "Ghost revision {%(revision_id)s} cannot be used here."
1270
1597
def __init__(self, revision_id):
1271
BzrNewError.__init__(self)
1598
BzrError.__init__(self)
1272
1599
self.revision_id = revision_id
1275
class IllegalUseOfScopeReplacer(BzrNewError):
1276
"""ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"""
1278
is_user_error = False
1602
class IllegalUseOfScopeReplacer(BzrError):
1604
_fmt = "ScopeReplacer object %(name)r was used incorrectly: %(msg)s%(extra)s"
1606
internal_error = True
1280
1608
def __init__(self, name, msg, extra=None):
1281
BzrNewError.__init__(self)
1609
BzrError.__init__(self)
1282
1610
self.name = name