From e163927416dceda2d626c4bb265d942094d63ce3 Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Sun, 12 May 2024 16:11:48 +0200 Subject: Fix CLI exit when FileNotFound error on routine --- cli/openbb_cli/controllers/cli_controller.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/openbb_cli/controllers/cli_controller.py b/cli/openbb_cli/controllers/cli_controller.py index 7969f74826b..5f16f070229 100644 --- a/cli/openbb_cli/controllers/cli_controller.py +++ b/cli/openbb_cli/controllers/cli_controller.py @@ -423,8 +423,9 @@ class CLIController(BaseController): else: return - with open(routine_path) as fp: - raw_lines = list(fp) + try: + with open(routine_path) as fp: + raw_lines = list(fp) # Capture ARGV either as list if args separated by commas or as single value if ns_parser.routine_args: @@ -478,6 +479,12 @@ class CLIController(BaseController): ) self.queue = self.queue[1:] + except FileNotFoundError: + session.console.print( + f"[red]File '{routine_path}' doesn't exist.[/red]\n" + ) + return + def handle_job_cmds(jobs_cmds: Optional[List[str]]) -> Optional[List[str]]: """Handle job commands.""" -- cgit v1.2.3