# HG changeset patch # User Martin von Zweigbergk # Date 1621398732 25200 # Node ID 5a75be9163165691e1c370d2e34a066d28ab2941 # Parent d9c71bbe20f7e9c056b2f17d67164091f85d3c6d errors: create superclass for Abort exception I'd like to let extensions subclass `StorageError` to define a custom exit code. However, `StorageError` does not extend `Abort` (which is where the exit code currently lives), and it seems that it's not supposed to either (`StorageError` seems to be for lower-level errors and `Abort` is for command-level errors). This patch therefore extracts all the code from `Abort` into a new `Error` class, which I'll soon make `StorageError` also extend. Differential Revision: https://phab.mercurial-scm.org/D10738 diff -r d9c71bbe20f7 -r 5a75be916316 mercurial/error.py --- a/mercurial/error.py Tue May 18 22:07:16 2021 -0700 +++ b/mercurial/error.py Tue May 18 21:32:12 2021 -0700 @@ -51,8 +51,8 @@ super(Hint, self).__init__(*args, **kw) -class Abort(Hint, Exception): - """Raised if a command needs to print an error and exit.""" +class Error(Hint, Exception): + """Base class for Mercurial errors.""" def __init__( self, message, hint=None, coarse_exit_code=None, detailed_exit_code=None @@ -87,6 +87,10 @@ return message +class Abort(Error): + """Raised if a command needs to print an error and exit.""" + + class StorageError(Hint, Exception): """Raised when an error occurs in a storage layer.