MCPcopy Index your code
hub / github.com/pyinvoke/invoke / Exit

Class Exit

invoke/exceptions.py:207–238  ·  view source on GitHub ↗

Simple custom stand-in for SystemExit. Replaces scattered sys.exit calls, improves testability, allows one to catch an exit request without intercepting real SystemExits (typically an unfriendly thing to do, as most users calling `sys.exit` rather expect it to truly exit.)

Source from the content-addressed store, hash-verified

205
206
207class Exit(Exception):
208 """
209 Simple custom stand-in for SystemExit.
210
211 Replaces scattered sys.exit calls, improves testability, allows one to
212 catch an exit request without intercepting real SystemExits (typically an
213 unfriendly thing to do, as most users calling `sys.exit` rather expect it
214 to truly exit.)
215
216 Defaults to a non-printing, exit-0 friendly termination behavior if the
217 exception is uncaught.
218
219 If ``code`` (an int) given, that code is used to exit.
220
221 If ``message`` (a string) given, it is printed to standard error, and the
222 program exits with code ``1`` by default (unless overridden by also giving
223 ``code`` explicitly.)
224
225 .. versionadded:: 1.0
226 """
227
228 def __init__(
229 self, message: Optional[str] = None, code: Optional[int] = None
230 ) -> None:
231 self.message = message
232 self._code = code
233
234 @property
235 def code(self) -> int:
236 if self._code is not None:
237 return self._code
238 return 1 if self.message else 0
239
240
241class PlatformError(Exception):

Callers 9

integrationFunction · 0.90
defaults_to_exiting_0Method · 0.90
parse_cleanupMethod · 0.85
load_collectionMethod · 0.85
list_tasksMethod · 0.85
list_jsonMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…