equal
deleted
inserted
replaced
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: |
167 |
172 |
168 class Abort(Hint, Exception): |
173 class Abort(Hint, Exception): |
169 """Raised if a command needs to print an error and exit.""" |
174 """Raised if a command needs to print an error and exit.""" |
170 |
175 |
171 def __init__(self, message, hint=None): |
176 def __init__(self, message, hint=None): |
|
177 # type: (bytes, Optional[bytes]) -> None |
172 self.message = message |
178 self.message = message |
173 self.hint = hint |
179 self.hint = hint |
174 # Pass the message into the Exception constructor to help extensions |
180 # Pass the message into the Exception constructor to help extensions |
175 # that look for exc.args[0]. |
181 # that look for exc.args[0]. |
176 Exception.__init__(self, message) |
182 Exception.__init__(self, message) |