bundle2: use a more specific UnknownPartError when no handler is found stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 21 Apr 2014 19:42:40 -0700
branchstable
changeset 21179 372f4772f7a0
parent 21178 9a813e703172
child 21180 b056777221bf
bundle2: use a more specific UnknownPartError when no handler is found KeyError is very generic, we need something more specific for proper error handling.
mercurial/bundle2.py
--- a/mercurial/bundle2.py	Mon Apr 21 15:59:55 2014 -0700
+++ b/mercurial/bundle2.py	Mon Apr 21 19:42:40 2014 -0700
@@ -170,6 +170,10 @@
     """
     return '>'+('BB'*nbparams)
 
+class UnknownPartError(KeyError):
+    """error raised when no handler is found for a Mandatory part"""
+    pass
+
 parthandlermapping = {}
 
 def parthandler(parttype):
@@ -297,7 +301,7 @@
                 if key != parttype: # mandatory parts
                     # todo:
                     # - use a more precise exception
-                    raise
+                    raise UnknownPartError(key)
                 op.ui.debug('ignoring unknown advisory part %r\n' % key)
                 # consuming the part
                 part.read()