exceptions¶
Custom exception classes.
These vary in use case from “we needed a specific data structure layout in exceptions used for message-passing” to simply “we needed to express an error condition in a way easily told apart from other, truly unexpected errors”.
-
exception
invoke.exceptions.AmbiguousEnvVar¶ Raised when loading env var config keys has an ambiguous target.
New in version 1.0.
-
__weakref__¶ list of weak references to the object (if defined)
-
-
exception
invoke.exceptions.AuthFailure(result, prompt)¶ An authentication failure, e.g. due to an incorrect
sudopassword.Note
Resultobjects attached to these exceptions typically lack exit code information, since the command was never fully executed - the exception was raised instead.New in version 1.0.
-
__init__(result, prompt)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__str__() <==> str(x)¶
-
-
exception
invoke.exceptions.CollectionNotFound(name, start)¶ -
__init__(name, start)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__weakref__¶ list of weak references to the object (if defined)
-
-
exception
invoke.exceptions.Exit(message=None, code=None)¶ 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.exitrather expect it to truly exit.)Defaults to a non-printing, exit-0 friendly termination behavior if the exception is uncaught.
If
code(an int) given, that code is used to exit.If
message(a string) given, it is printed to standard error, and the program exits with code1by default (unless overridden by also givingcodeexplicitly.)New in version 1.0.
-
__init__(message=None, code=None)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__weakref__¶ list of weak references to the object (if defined)
-
-
exception
invoke.exceptions.Failure(result, reason=None)¶ Exception subclass representing failure of a command execution.
“Failure” may mean the command executed and the shell indicated an unusual result (usually, a non-zero exit code), or it may mean something else, like a
sudocommand which was aborted when the supplied password failed authentication.Two attributes allow introspection to determine the nature of the problem:
result: aResultinstance with info about the command being executed and, if it ran to completion, how it exited.reason:None, if the command finished; or an exception instance if e.g. aStreamWatcherraisedWatcherError.
This class is only rarely raised by itself; most of the time
Runner.run(or a wrapper of same, such asContext.sudo) will raise a specific subclass likeUnexpectedExitorAuthFailure.New in version 1.0.
-
__init__(result, reason=None)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__weakref__¶ list of weak references to the object (if defined)
-
exception
invoke.exceptions.ParseError(msg, context=None)¶ An error arising from the parsing of command-line flags/arguments.
Ambiguous input, invalid task names, invalid flags, etc.
New in version 1.0.
-
__init__(msg, context=None)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__weakref__¶ list of weak references to the object (if defined)
-
-
exception
invoke.exceptions.PlatformError¶ Raised when an illegal operation occurs for the current platform.
E.g. Windows users trying to use functionality requiring the
ptymodule.Typically used to present a clearer error message to the user.
New in version 1.0.
-
__weakref__¶ list of weak references to the object (if defined)
-
-
exception
invoke.exceptions.ResponseNotAccepted¶ A responder/watcher class noticed a ‘bad’ response to its submission.
Mostly used by
FailingResponderand subclasses, e.g. “oh dear I autosubmitted a sudo password and it was incorrect.”New in version 1.0.
-
exception
invoke.exceptions.ThreadException(exceptions)¶ One or more exceptions were raised within background threads.
The real underlying exceptions are stored in the
exceptionsattribute; see its documentation for data structure details.Note
Threads which did not encounter an exception, do not contribute to this exception object and thus are not present inside
exceptions.New in version 1.0.
-
__init__(exceptions)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
__str__() <==> str(x)¶
-
__weakref__¶ list of weak references to the object (if defined)
-
exceptions= ()¶ A tuple of
ExceptionWrapperscontaining the initial thread constructor kwargs (becausethreading.Threadsubclasses should always be called with kwargs) and the caught exception for that thread as seen bysys.exc_info(so: type, value, traceback).Note
The ordering of this attribute is not well-defined.
Note
Thread kwargs which appear to be very long (e.g. IO buffers) will be truncated when printed, to avoid huge unreadable error display.
-
-
exception
invoke.exceptions.UncastableEnvVar¶ Raised on attempted env var loads whose default values are too rich.
E.g. trying to stuff
MY_VAR="foo"into{'my_var': ['uh', 'oh']}doesn’t make any sense until/if we implement some sort of transform option.New in version 1.0.
-
__weakref__¶ list of weak references to the object (if defined)
-
-
exception
invoke.exceptions.UnexpectedExit(result, reason=None)¶ A shell command ran to completion but exited with an unexpected exit code.
Its string representation displays the following:
- Command executed;
- Exit code;
- The last 10 lines of stdout, if it was hidden;
- The last 10 lines of stderr, if it was hidden and non-empty (e.g. pty=False; when pty=True, stderr never happens.)
New in version 1.0.
-
__repr__() <==> repr(x)¶
-
__str__() <==> str(x)¶
-
exception
invoke.exceptions.UnknownFileType¶ A config file of an unknown type was specified and cannot be loaded.
New in version 1.0.
-
__weakref__¶ list of weak references to the object (if defined)
-
-
exception
invoke.exceptions.WatcherError¶ Generic parent exception class for
StreamWatcher-related errors.Typically, one of these exceptions indicates a
StreamWatchernoticed something anomalous in an output stream, such as an authentication response failure.Runnercatches these and attaches them toFailureexceptions so they can be referenced by intermediate code and/or act as extra info for end users.New in version 1.0.
-
__weakref__¶ list of weak references to the object (if defined)
-