From 7024aa0e705e522e8e0cc9b4555bb17a5a35ed45 Mon Sep 17 00:00:00 2001 From: Kevin Van Brunt Date: Tue, 2 Mar 2021 10:26:45 -0500 Subject: Added cmd2.exceptions.PassThroughException --- cmd2/exceptions.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmd2/exceptions.py') diff --git a/cmd2/exceptions.py b/cmd2/exceptions.py index 39b7e333..b45167d1 100644 --- a/cmd2/exceptions.py +++ b/cmd2/exceptions.py @@ -62,6 +62,21 @@ class CompletionError(Exception): super().__init__(*args) +class PassThroughException(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. + """ + + def __init__(self, *args, wrapped_ex: BaseException): + """ + Initializer for PassThroughException + :param wrapped_ex: the exception that will be raised + """ + self.wrapped_ex = wrapped_ex + super().__init__(*args) + + ############################################################################################################ # The following exceptions are NOT part of the public API and are intended for internal use only. ############################################################################################################ -- cgit v1.2.1