Patchwork D10741: errors: make StorageError subclass Error, attaching an exit code to it

login
register
mail settings
Submitter phabricator
Date May 19, 2021, 5:48 a.m.
Message ID <differential-rev-PHID-DREV-d65w3a56leiovsp7rk7i-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49060/
State Superseded
Headers show

Comments

phabricator - May 19, 2021, 5:48 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10741

AFFECTED FILES
  mercurial/error.py
  mercurial/scmutil.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -198,11 +198,6 @@ 
             ui.error(b"\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
     except error.CensoredNodeError as inst:
         ui.error(_(b"abort: file censored %s\n") % inst)
-    except error.StorageError as inst:
-        ui.error(_(b"abort: %s\n") % inst)
-        if inst.hint:
-            ui.error(_(b"(%s)\n") % inst.hint)
-        detailed_exit_code = 50
     except error.WdirUnsupported:
         ui.error(_(b"abort: working directory revision cannot be specified\n"))
     except error.Error as inst:
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -91,13 +91,16 @@ 
     """Raised if a command needs to print an error and exit."""
 
 
-class StorageError(Hint, Exception):
+class StorageError(Error):
     """Raised when an error occurs in a storage layer.
 
     Usually subclassed by a storage-specific exception.
     """
 
-    __bytes__ = _tobytes
+    def __init__(self, message, hint=None):
+        super(StorageError, self).__init__(
+            message, hint=hint, detailed_exit_code=50
+        )
 
 
 class RevlogError(StorageError):