33
33
# TODO: is there any value in providing the .args field used by standard
34
# python exceptions? A list of values with no names seems less useful
34
# python exceptions? A list of values with no names seems less useful
37
# TODO: Perhaps convert the exception to a string at the moment it's
37
# TODO: Perhaps convert the exception to a string at the moment it's
38
38
# constructed to make sure it will succeed. But that says nothing about
39
39
# exceptions that are never raised.
72
72
arguments can be given. The first is for generic "user" errors which
73
73
are not intended to be caught and so do not need a specific subclass.
74
74
The second case is for use with subclasses that provide a _fmt format
75
string to print the arguments.
75
string to print the arguments.
77
Keyword arguments are taken as parameters to the error, which can
78
be inserted into the format string template. It's recommended
79
that subclasses override the __init__ method to require specific
77
Keyword arguments are taken as parameters to the error, which can
78
be inserted into the format string template. It's recommended
79
that subclasses override the __init__ method to require specific
82
82
:param msg: If given, this is the literal complete text for the error,
477
477
def __init__(self, name, value):
478
478
BzrError.__init__(self, name=name, value=value)
481
481
class StrictCommitFailed(BzrError):
483
483
_fmt = "Commit refused because there are unknown files in the tree"
486
486
# XXX: Should be unified with TransportError; they seem to represent the
488
488
# RBC 20060929: I think that unifiying with TransportError would be a mistake
489
# - this is finer than a TransportError - and more useful as such. It
489
# - this is finer than a TransportError - and more useful as such. It
490
490
# differentiates between 'transport has failed' and 'operation on a transport
492
492
class PathError(BzrError):
494
494
_fmt = "Generic path error: %(path)r%(extra)s)"
496
496
def __init__(self, path, extra=None):
690
690
# TODO: This is given a URL; we try to unescape it but doing that from inside
691
691
# the exception object is a bit undesirable.
692
# TODO: Probably this behavior of should be a common superclass
692
# TODO: Probably this behavior of should be a common superclass
693
693
class NotBranchError(PathError):
695
695
_fmt = 'Not a branch: "%(path)s".'
1004
1004
class LockContention(LockError):
1006
_fmt = 'Could not acquire lock "%(lock)s"'
1006
_fmt = 'Could not acquire lock "%(lock)s": %(msg)s'
1007
1007
# TODO: show full url for lock, combining the transport and relative
1010
1010
internal_error = False
1012
def __init__(self, lock):
1012
def __init__(self, lock, msg=''):
1013
1013
self.lock = lock
1016
1017
class LockBroken(LockError):
1131
1132
class NoSuchRevisionInTree(NoSuchRevision):
1132
1133
"""When using Tree.revision_tree, and the revision is not accessible."""
1134
1135
_fmt = "The revision id {%(revision_id)s} is not present in the tree %(tree)s."
1136
1137
def __init__(self, tree, revision_id):
1384
1385
class VersionedFileError(BzrError):
1386
1387
_fmt = "Versioned file error"
1389
1390
class RevisionNotPresent(VersionedFileError):
1391
1392
_fmt = 'Revision {%(revision_id)s} not present in "%(file_id)s".'
1393
1394
def __init__(self, revision_id, file_id):
1450
1451
def __init__(self, stream_format, target_format):
1451
1452
self.stream_format = stream_format
1452
1453
self.target_format = target_format
1455
1456
class KnitDataStreamUnknown(KnitError):
1456
1457
# Indicates a data stream we don't know how to handle.
2049
2052
_fmt = """This tree contains left-over files from a failed operation.
2050
2053
Please examine %(limbo_dir)s to see if it contains any files you wish to
2051
2054
keep, and delete it when you are done."""
2053
2056
def __init__(self, limbo_dir):
2054
2057
BzrError.__init__(self)
2055
2058
self.limbo_dir = limbo_dir
2245
2248
self.text = text
2248
class MalformedHeader(BadBundle):
2251
class MalformedHeader(BadBundle):
2250
2253
_fmt = "Malformed bzr revision-bundle header: %(text)r"
2253
class MalformedPatches(BadBundle):
2256
class MalformedPatches(BadBundle):
2255
2258
_fmt = "Malformed patches in bzr revision-bundle: %(text)r"
2258
class MalformedFooter(BadBundle):
2261
class MalformedFooter(BadBundle):
2260
2263
_fmt = "Malformed footer in bzr revision-bundle: %(text)r"
2263
2266
class UnsupportedEOLMarker(BadBundle):
2265
_fmt = "End of line marker was not \\n in bzr revision-bundle"
2268
_fmt = "End of line marker was not \\n in bzr revision-bundle"
2267
2270
def __init__(self):
2268
# XXX: BadBundle's constructor assumes there's explanatory text,
2271
# XXX: BadBundle's constructor assumes there's explanatory text,
2269
2272
# but for this there is not
2270
2273
BzrError.__init__(self)
2273
2276
class IncompatibleBundleFormat(BzrError):
2275
2278
_fmt = "Bundle format %(bundle_format)s is incompatible with %(other)s"
2277
2280
def __init__(self, bundle_format, other):
2502
2505
class MalformedBugIdentifier(BzrError):
2504
_fmt = "Did not understand bug identifier %(bug_id)s: %(reason)s"
2507
_fmt = ('Did not understand bug identifier %(bug_id)s: %(reason)s. '
2508
'See "bzr help bugs" for more information on this feature.')
2506
2510
def __init__(self, bug_id, reason):
2507
2511
self.bug_id = bug_id
2528
2532
self.branch = branch
2535
class InvalidLineInBugsProperty(BzrError):
2537
_fmt = ("Invalid line in bugs property: '%(line)s'")
2539
def __init__(self, line):
2543
class InvalidBugStatus(BzrError):
2545
_fmt = ("Invalid bug status: '%(status)s'")
2547
def __init__(self, status):
2548
self.status = status
2531
2551
class UnexpectedSmartServerResponse(BzrError):
2533
2553
_fmt = "Could not understand response from smart server: %(response_tuple)r"
2744
2764
_fmt = "'%(display_url)s' is already standalone."
2767
class AlreadyWithTrees(BzrDirError):
2769
_fmt = ("Shared repository '%(display_url)s' already creates "
2773
class AlreadyWithNoTrees(BzrDirError):
2775
_fmt = ("Shared repository '%(display_url)s' already doesn't create "
2747
2779
class ReconfigurationNotSupported(BzrDirError):
2749
2781
_fmt = "Requested reconfiguration of '%(display_url)s' is not supported."
2805
2837
class CommandAvailableInPlugin(StandardError):
2807
2839
internal_error = False
2809
2841
def __init__(self, cmd_name, plugin_metadata, provider):
2811
2843
self.plugin_metadata = plugin_metadata
2812
2844
self.cmd_name = cmd_name
2813
2845
self.provider = provider
2815
2847
def __str__(self):
2817
_fmt = ('"%s" is not a standard bzr command. \n'
2849
_fmt = ('"%s" is not a standard bzr command. \n'
2818
2850
'However, the following official plugin provides this command: %s\n'
2819
2851
'You can install it by going to: %s'
2820
% (self.cmd_name, self.plugin_metadata['name'],
2852
% (self.cmd_name, self.plugin_metadata['name'],
2821
2853
self.plugin_metadata['url']))
2826
2858
class NoPluginAvailable(BzrError):
2830
2862
class NotATerminal(BzrError):
2934
2966
BzrError.__init__(self, shelf_id=shelf_id)
2969
class InvalidShelfId(BzrError):
2971
_fmt = '"%(invalid_id)s" is not a valid shelf id, try a number instead.'
2973
def __init__(self, invalid_id):
2974
BzrError.__init__(self, invalid_id=invalid_id)
2937
2977
class UserAbort(BzrError):
2939
2979
_fmt = 'The user aborted the operation.'
2982
class MustHaveWorkingTree(BzrError):
2984
_fmt = ("Branching '%(url)s'(%(format)s) must create a working tree.")
2986
def __init__(self, format, url):
2987
BzrError.__init__(self, format=format, url=url)
2990
class NoSuchView(BzrError):
2991
"""A view does not exist.
2994
_fmt = u"No such view: %(view_name)s."
2996
def __init__(self, view_name):
2997
self.view_name = view_name
3000
class ViewsNotSupported(BzrError):
3001
"""Views are not supported by a tree format.
3004
_fmt = ("Views are not supported by %(tree)s;"
3005
" use 'bzr upgrade' to change your tree to a later format.")
3007
def __init__(self, tree):
3011
class FileOutsideView(BzrError):
3013
_fmt = ('Specified file "%(file_name)s" is outside the current view: '
3016
def __init__(self, file_name, view_files):
3017
self.file_name = file_name
3018
self.view_str = ", ".join(view_files)
3021
class UnresumableWriteGroup(BzrError):
3023
_fmt = ("Repository %(repository)s cannot resume write group "
3024
"%(write_groups)r: %(reason)s")
3026
internal_error = True
3028
def __init__(self, repository, write_groups, reason):
3029
self.repository = repository
3030
self.write_groups = write_groups
3031
self.reason = reason
3034
class UnsuspendableWriteGroup(BzrError):
3036
_fmt = ("Repository %(repository)s cannot suspend a write group.")
3038
internal_error = True
3040
def __init__(self, repository):
3041
self.repository = repository