Rev 2872: * New class ``bzrlib.errors.InternalBzrError`` which is just a convenient in http://people.ubuntu.com/~robertc/baz2.0/commit-builder

Robert Collins robertc at robertcollins.net
Fri Sep 28 01:48:25 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/commit-builder

------------------------------------------------------------
revno: 2872
revision-id: robertc at robertcollins.net-20070928004802-8dls2udp5ekh2ubr
parent: pqm at pqm.ubuntu.com-20070927065437-oc8enxoek80hyxod
committer: Robert Collins <robertc at robertcollins.net>
branch nick: commit-builder
timestamp: Fri 2007-09-28 10:48:02 +1000
message:
  * New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
    shorthand for deriving from BzrError and setting internal_error = True.
    (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
=== modified file 'NEWS'
--- a/NEWS	2007-09-26 02:36:24 +0000
+++ b/NEWS	2007-09-28 00:48:02 +0000
@@ -136,6 +136,10 @@
       put by the method call, to allow avoiding stat-after-write or
       housekeeping in callers. (Robert Collins)
 
+   * New class ``bzrlib.errors.InternalBzrError`` which is just a convenient
+     shorthand for deriving from BzrError and setting internal_error = True.
+     (Robert Collins)
+
    * New method ``bzrlib.osutils.minimum_path_selection`` useful for removing
      duplication from user input, when a user mentions both a path and an item
      contained within that path. (Robert Collins)

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2007-09-26 04:49:43 +0000
+++ b/bzrlib/errors.py	2007-09-28 00:48:02 +0000
@@ -130,6 +130,17 @@
                )
 
 
+class InternalBzrError(BzrError):
+    """Base class for errors that are internal in nature.
+
+    This is a convenience class for errors that are internal. The
+    internal_error attribute can still be altered in subclasses, if needed.
+    Using this class is simply an easy way to get internal errors.
+    """
+
+    internal_error = True
+
+
 class BzrNewError(BzrError):
     """Deprecated error base class."""
     # base classes should override the docstring with their human-
@@ -168,23 +179,19 @@
     _fmt = "The tree builder is already building a tree."
 
 
-class BzrCheckError(BzrError):
+class BzrCheckError(InternalBzrError):
     
     _fmt = "Internal check failed: %(message)s"
 
-    internal_error = True
-
     def __init__(self, message):
         BzrError.__init__(self)
         self.message = message
 
 
-class DisabledMethod(BzrError):
+class DisabledMethod(InternalBzrError):
 
     _fmt = "The smart server method '%(class_name)s' is disabled."
 
-    internal_error = True
-
     def __init__(self, class_name):
         BzrError.__init__(self)
         self.class_name = class_name
@@ -211,12 +218,10 @@
         self.transport = transport
 
 
-class InvalidEntryName(BzrError):
+class InvalidEntryName(InternalBzrError):
     
     _fmt = "Invalid entry name: %(name)s"
 
-    internal_error = True
-
     def __init__(self, name):
         BzrError.__init__(self)
         self.name = name
@@ -249,6 +254,9 @@
         self.revision_id = revision_id
 
 
+class RootMissing(BzrError):
+
+
 class NoHelpTopic(BzrError):
 
     _fmt = ("No help could be found for '%(topic)s'. "
@@ -277,13 +285,11 @@
         BzrError.__init__(self, repository=repository, file_id=file_id)
 
 
-class InventoryModified(BzrError):
+class InventoryModified(InternalBzrError):
 
     _fmt = ("The current inventory for the tree %(tree)r has been modified,"
             " so a clean inventory cannot be read without data loss.")
 
-    internal_error = True
-
     def __init__(self, tree):
         self.tree = tree
 
@@ -310,20 +316,17 @@
         self.url = url
 
 
-class WorkingTreeAlreadyPopulated(BzrError):
+class WorkingTreeAlreadyPopulated(InternalBzrError):
 
     _fmt = 'Working tree already populated in "%(base)s"'
 
-    internal_error = True
-
     def __init__(self, base):
         self.base = base
 
+
 class BzrCommandError(BzrError):
     """Error from user command"""
 
-    internal_error = False
-
     # Error from malformed user command; please avoid raising this as a
     # generic exception not caused by user input.
     #
@@ -485,14 +488,12 @@
     _fmt = 'Directory not empty: "%(path)s"%(extra)s'
 
 
-class ReadingCompleted(BzrError):
+class ReadingCompleted(InternalBzrError):
     
     _fmt = ("The MediumRequest '%(request)s' has already had finish_reading "
             "called upon it - the request has been completed and no more "
             "data may be read.")
 
-    internal_error = True
-
     def __init__(self, request):
         self.request = request
 
@@ -774,12 +775,10 @@
     _fmt = 'Cannot operate on "%(filename)s" because it is a control file'
 
 
-class LockError(BzrError):
+class LockError(InternalBzrError):
 
     _fmt = "Lock error: %(msg)s"
 
-    internal_error = True
-
     # All exceptions from the lock/unlock functions should be from
     # this exception class.  They will be translated as necessary. The
     # original exception is available as e.original_error
@@ -922,8 +921,6 @@
 
     _fmt = "The object %(obj)s does not support token specifying a token when locking."
 
-    internal_error = True
-
     def __init__(self, obj):
         self.obj = obj
 
@@ -979,25 +976,21 @@
     _fmt = "Commit refused because there are unknowns in the tree."
 
 
-class NoSuchRevision(BzrError):
+class NoSuchRevision(InternalBzrError):
 
     _fmt = "%(branch)s has no revision %(revision)s"
 
-    internal_error = True
-
     def __init__(self, branch, revision):
         # 'branch' may sometimes be an internal object like a KnitRevisionStore
         BzrError.__init__(self, branch=branch, revision=revision)
 
 
 # zero_ninetyone: this exception is no longer raised and should be removed
-class NotLeftParentDescendant(BzrError):
+class NotLeftParentDescendant(InternalBzrError):
 
     _fmt = ("Revision %(old_revision)s is not the left parent of"
             " %(new_revision)s, but branch %(branch_location)s expects this")
 
-    internal_error = True
-
     def __init__(self, branch, old_revision, new_revision):
         BzrError.__init__(self, branch_location=branch.base,
                           old_revision=old_revision,
@@ -1063,19 +1056,15 @@
     _fmt = ("These branches have diverged."
             " Use the merge command to reconcile them.")
 
-    internal_error = False
-
     def __init__(self, branch1, branch2):
         self.branch1 = branch1
         self.branch2 = branch2
 
 
-class NotLefthandHistory(BzrError):
+class NotLefthandHistory(InternalBzrError):
 
     _fmt = "Supplied history does not follow left-hand parents"
 
-    internal_error = True
-
     def __init__(self, history):
         BzrError.__init__(self, history=history)
 
@@ -1085,8 +1074,6 @@
     _fmt = ("Branches have no common ancestor, and"
             " no merge base revision was specified.")
 
-    internal_error = False
-
 
 class NoCommonAncestor(BzrError):
     
@@ -1303,12 +1290,10 @@
     _fmt = "Text did not match its checksum: %(message)s"
 
 
-class KnitError(BzrError):
+class KnitError(InternalBzrError):
     
     _fmt = "Knit error"
 
-    internal_error = True
-
 
 class KnitCorrupt(KnitError):
 
@@ -1378,14 +1363,12 @@
         BzrError.__init__(self)
 
 
-class TooManyConcurrentRequests(BzrError):
+class TooManyConcurrentRequests(InternalBzrError):
 
     _fmt = ("The medium '%(medium)s' has reached its concurrent request limit."
             " Be sure to finish_writing and finish_reading on the"
             " currently open request.")
 
-    internal_error = True
-
     def __init__(self, medium):
         self.medium = medium
 
@@ -1581,25 +1564,21 @@
         self.graph = graph
 
 
-class WritingCompleted(BzrError):
+class WritingCompleted(InternalBzrError):
 
     _fmt = ("The MediumRequest '%(request)s' has already had finish_writing "
             "called upon it - accept bytes may not be called anymore.")
 
-    internal_error = True
-
     def __init__(self, request):
         self.request = request
 
 
-class WritingNotComplete(BzrError):
+class WritingNotComplete(InternalBzrError):
 
     _fmt = ("The MediumRequest '%(request)s' has not has finish_writing "
             "called upon it - until the write phase is complete no "
             "data may be read.")
 
-    internal_error = True
-
     def __init__(self, request):
         self.request = request
 
@@ -1613,12 +1592,10 @@
         self.filename = filename
 
 
-class MediumNotConnected(BzrError):
+class MediumNotConnected(InternalBzrError):
 
     _fmt = """The medium '%(medium)s' is not connected."""
 
-    internal_error = True
-
     def __init__(self, medium):
         self.medium = medium
 
@@ -1700,12 +1677,10 @@
         self.root_trans_id = transform.root
 
 
-class BzrBadParameter(BzrError):
+class BzrBadParameter(InternalBzrError):
 
     _fmt = "Bad parameter: %(param)r"
 
-    internal_error = True
-
     # This exception should never be thrown, but it is a base class for all
     # parameter-to-function errors.
 
@@ -2094,12 +2069,10 @@
     _fmt = """This operation requires rich root data storage"""
 
 
-class NoSmartMedium(BzrError):
+class NoSmartMedium(InternalBzrError):
 
     _fmt = "The transport '%(transport)s' cannot tunnel the smart protocol."
 
-    internal_error = True
-
     def __init__(self, transport):
         self.transport = transport
 
@@ -2136,13 +2109,11 @@
         self.revision_id = revision_id
 
 
-class IllegalUseOfScopeReplacer(BzrError):
+class IllegalUseOfScopeReplacer(InternalBzrError):
 
     _fmt = ("ScopeReplacer object %(name)r was used incorrectly:"
             " %(msg)s%(extra)s")
 
-    internal_error = True
-
     def __init__(self, name, msg, extra=None):
         BzrError.__init__(self)
         self.name = name
@@ -2153,25 +2124,21 @@
             self.extra = ''
 
 
-class InvalidImportLine(BzrError):
+class InvalidImportLine(InternalBzrError):
 
     _fmt = "Not a valid import statement: %(msg)\n%(text)s"
 
-    internal_error = True
-
     def __init__(self, text, msg):
         BzrError.__init__(self)
         self.text = text
         self.msg = msg
 
 
-class ImportNameCollision(BzrError):
+class ImportNameCollision(InternalBzrError):
 
     _fmt = ("Tried to import an object to the same name as"
             " an existing object. %(name)s")
 
-    internal_error = True
-
     def __init__(self, name):
         BzrError.__init__(self)
         self.name = name
@@ -2242,13 +2209,11 @@
         self.other_tree = other_tree
 
 
-class BadReferenceTarget(BzrError):
+class BadReferenceTarget(InternalBzrError):
 
     _fmt = "Can't add reference to %(other_tree)s into %(tree)s." \
            "%(reason)s"
 
-    internal_error = True
-
     def __init__(self, tree, other_tree, reason):
         self.tree = tree
         self.other_tree = other_tree
@@ -2323,8 +2288,6 @@
 
     _fmt = "Unexpected end of container stream"
 
-    internal_error = False
-
 
 class UnknownRecordTypeError(ContainerError):
 
@@ -2358,12 +2321,10 @@
         self.name = name
 
 
-class NoDestinationAddress(BzrError):
+class NoDestinationAddress(InternalBzrError):
 
     _fmt = "Message does not have a destination address."
 
-    internal_error = True
-
 
 class SMTPError(BzrError):
 



More information about the bazaar-commits mailing list