comparison mercurial/error.py @ 45827:8d72e29ad1e0

errors: introduce InputError and use it from commands and cmdutil This patch introduces a `InputError` class and replaces many uses of `error.Abort` by it in `commands` and `cmdutil`. This is a part of https://www.mercurial-scm.org/wiki/ErrorCategoriesPlan. There will later be a different class for state errors (to raise e.g. when there's an unfinished operation). It's not always clear when one should report an input error and when it should be a state error. We can always adjust later if I got something wrong in this patch (but feel free to point out any you notice now). Differential Revision: https://phab.mercurial-scm.org/D9167
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 06 Oct 2020 22:36:15 -0700
parents 8f07f5a9c3de
children 527ce85c2e60
comparison
equal deleted inserted replaced
45826:21733e8c924f 45827:8d72e29ad1e0
177 def __str__(self): 177 def __str__(self):
178 # the output would be unreadable if the message was translated, 178 # the output would be unreadable if the message was translated,
179 # but do not replace it with encoding.strfromlocal(), which 179 # but do not replace it with encoding.strfromlocal(), which
180 # may raise another exception. 180 # may raise another exception.
181 return pycompat.sysstr(self.__bytes__()) 181 return pycompat.sysstr(self.__bytes__())
182
183
184 class InputError(Abort):
185 """Indicates that the user made an error in their input.
186
187 Examples: Invalid command, invalid flags, invalid revision.
188 """
182 189
183 190
184 class HookLoadError(Abort): 191 class HookLoadError(Abort):
185 """raised when loading a hook fails, aborting an operation 192 """raised when loading a hook fails, aborting an operation
186 193