summaryrefslogtreecommitdiff
path: root/cmd2/exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2/exceptions.py')
-rw-r--r--cmd2/exceptions.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/cmd2/exceptions.py b/cmd2/exceptions.py
index 635192e1..d0a922db 100644
--- a/cmd2/exceptions.py
+++ b/cmd2/exceptions.py
@@ -1,16 +1,33 @@
# coding=utf-8
-"""Custom exceptions for cmd2. These are NOT part of the public API and are intended for internal use only."""
+"""Custom exceptions for cmd2"""
-class Cmd2ArgparseError(Exception):
+############################################################################################################
+# The following exceptions are part of the public API
+############################################################################################################
+
+class SkipPostcommandHooks(Exception):
"""
- Custom exception class for when a command has an error parsing its arguments.
- This can be raised by argparse decorators or the command functions themselves.
- The main use of this exception is to tell cmd2 not to run Postcommand hooks.
+ Custom exception class for when a command has a failure bad enough to skip post command
+ hooks, but not bad enough to print the exception to the user.
"""
pass
+class Cmd2ArgparseError(SkipPostcommandHooks):
+ """
+ A ``SkipPostcommandHooks`` exception for when a command fails parsing its arguments.
+ This is raised by argparse decorators but can also be raised by command functions.
+ If a command function still needs to run post command hooks when parsing fails,
+ just return instead of raising an exception.
+ """
+ pass
+
+
+############################################################################################################
+# The following exceptions are NOT part of the public API and are intended for internal use only.
+############################################################################################################
+
class Cmd2ShlexError(Exception):
"""Raised when shlex fails to parse a command line string in StatementParser"""
pass