Mercurial > hg
comparison mercurial/error.py @ 46794:e2f7b2695ba1
merge with stable
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 18 Mar 2021 18:24:59 -0400 |
parents | 6fc57680cfd6 ae62ab82a345 |
children | d4ba4d51f85f |
comparison
equal
deleted
inserted
replaced
46782:6b52cffd8d0a | 46794:e2f7b2695ba1 |
---|---|
15 | 15 |
16 import difflib | 16 import difflib |
17 | 17 |
18 # Do not import anything but pycompat here, please | 18 # Do not import anything but pycompat here, please |
19 from . import pycompat | 19 from . import pycompat |
20 | |
21 if pycompat.TYPE_CHECKING: | |
22 from typing import ( | |
23 Optional, | |
24 ) | |
20 | 25 |
21 | 26 |
22 def _tobytes(exc): | 27 def _tobytes(exc): |
23 """Byte-stringify exception in the same way as BaseException_str()""" | 28 """Byte-stringify exception in the same way as BaseException_str()""" |
24 if not exc.args: | 29 if not exc.args: |
168 | 173 |
169 class Abort(Hint, Exception): | 174 class Abort(Hint, Exception): |
170 """Raised if a command needs to print an error and exit.""" | 175 """Raised if a command needs to print an error and exit.""" |
171 | 176 |
172 def __init__(self, message, hint=None): | 177 def __init__(self, message, hint=None): |
178 # type: (bytes, Optional[bytes]) -> None | |
173 self.message = message | 179 self.message = message |
174 self.hint = hint | 180 self.hint = hint |
175 # Pass the message into the Exception constructor to help extensions | 181 # Pass the message into the Exception constructor to help extensions |
176 # that look for exc.args[0]. | 182 # that look for exc.args[0]. |
177 Exception.__init__(self, message) | 183 Exception.__init__(self, message) |