diff --git a/flytekit/clis/sdk_in_container/utils.py b/flytekit/clis/sdk_in_container/utils.py index c31b1e6502..9a5fdaa890 100644 --- a/flytekit/clis/sdk_in_container/utils.py +++ b/flytekit/clis/sdk_in_container/utils.py @@ -113,11 +113,14 @@ def pretty_print_traceback(e: Exception, verbosity: int = 1): Print the traceback in a nice formatted way if verbose is set to True. """ console = Console() + unwanted_module_names = ["importlib", "click", "rich_click"] if verbosity == 0: - console.print(Traceback.from_exception(type(e), e, None)) + unwanted_module_names.append("flytekit") + tb = e.__cause__.__traceback__ if e.__cause__ else e.__traceback__ + new_tb = remove_unwanted_traceback_frames(tb, unwanted_module_names) + console.print(Traceback.from_exception(type(e), e, new_tb)) elif verbosity == 1: - unwanted_module_names = ["importlib", "click", "rich_click"] click.secho( f"Frames from the following modules were removed from the traceback: {unwanted_module_names}." f" For more verbose output, use the flags -vv or -vvv.",