cmd2.exceptions
cmd2.exceptions
Custom exceptions for cmd2.
SkipPostcommandHooks
Bases: Exception
For when a command has a failed bad enough to skip post command hooks, but not bad enough to print to the user.
Cmd2ArgparseError
Bases: SkipPostcommandHooks
A SkipPostcommandHooks exception for when a command fails to parse its arguments.
Normally argparse raises a SystemExit exception in these cases. To avoid stopping the command loop, catch the SystemExit and raise this instead. If you still need to run post command hooks after parsing fails, just return instead of raising an exception.
CommandSetRegistrationError
Bases: Exception
For when an error occurs while a CommandSet is being added or removed from a cmd2 application.
CompletionError
Bases: Exception
Raised during completion operations to report any sort of error you want printed.
Example use cases:
- Reading a database to retrieve a completion data set failed
- A previous command line argument that determines the data set being completed is invalid
Initialize CompletionError instance.
| PARAMETER | DESCRIPTION |
|---|---|
apply_style
|
If True, then styles.ERROR will be applied to the message text when printed. Set to False in cases where the message text already has the desired style. Defaults to True.
TYPE:
|
Source code in cmd2/exceptions.py
PassThroughException
Bases: Exception
Normally all unhandled exceptions raised during commands get printed to the user.
This class is used to wrap an exception that should be raised instead of printed.
Initialize PassThroughException instance.
| PARAMETER | DESCRIPTION |
|---|---|
wrapped_ex
|
the exception that will be raised.
TYPE:
|
Source code in cmd2/exceptions.py
Cmd2ShlexError
Bases: Exception
Raised when shlex fails to parse a command line string in StatementParser.
EmbeddedConsoleExit
Bases: SystemExit
Custom exception class for use with the py command.
EmptyStatement
Bases: Exception
Custom exception class for handling behavior when the user just presses
IncompleteStatement
Bases: Exception
Raised when more input is required to complete a multiline statement.
MacroError
Bases: Exception
Raised when a macro fails to resolve (e.g., insufficient arguments).
RedirectionError
Bases: Exception
Custom exception class for when redirecting or piping output fails.