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.
-
__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.
-
exception
invoke.exceptions.Exit(code=0)¶ Simple stand-in for SystemExit that lets us gracefully exit.
Removes lots of scattered sys.exit calls, improves testability.
-
__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.-
__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.
-
__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.
-
__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.”
-
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.-
__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.-
__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.)
-
exception
invoke.exceptions.UnknownFileType¶ A config file of an unknown type was specified and cannot be loaded.
-
__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.-
__weakref__¶ list of weak references to the object (if defined)
-