From a70a76962dba3d9cba26553bbf5c9176b5e26d8f Mon Sep 17 00:00:00 2001 From: orjuelanico Date: Tue, 1 Dec 2026 15:28:35 -0500 Subject: [PATCH] Group 10 Case Study 3 - Fix clone --- httpie/core.py | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/httpie/core.py b/httpie/core.py index d0c26dcbcc..bfb3a5107d 100644 --- a/httpie/core.py +++ b/httpie/core.py @@ -66,6 +66,16 @@ def handle_generic_error(e, annotation=None): if include_traceback: raise + def handle_interrupt(exc: BaseException) -> ExitStatus: + if isinstance(exc, SystemExit) and exc.code == ExitStatus.SUCCESS: + return ExitStatus.SUCCESS + env.stderr.write('\n') + if include_traceback: + raise + if isinstance(exc, KeyboardInterrupt): + return ExitStatus.ERROR_CTRL_C + return ExitStatus.ERROR + if include_debug_info: print_debug_info(env) if args == ['--debug']: @@ -83,17 +93,8 @@ def handle_generic_error(e, annotation=None): if include_traceback: raise exit_status = ExitStatus.ERROR - except KeyboardInterrupt: - env.stderr.write('\n') - if include_traceback: - raise - exit_status = ExitStatus.ERROR_CTRL_C - except SystemExit as e: - if e.code != ExitStatus.SUCCESS: - env.stderr.write('\n') - if include_traceback: - raise - exit_status = ExitStatus.ERROR + except (KeyboardInterrupt, SystemExit) as exc: + exit_status = handle_interrupt(exc) else: check_updates(env) try: @@ -101,17 +102,8 @@ def handle_generic_error(e, annotation=None): args=parsed_args, env=env, ) - except KeyboardInterrupt: - env.stderr.write('\n') - if include_traceback: - raise - exit_status = ExitStatus.ERROR_CTRL_C - except SystemExit as e: - if e.code != ExitStatus.SUCCESS: - env.stderr.write('\n') - if include_traceback: - raise - exit_status = ExitStatus.ERROR + except (KeyboardInterrupt, SystemExit) as exc: + exit_status = handle_interrupt(exc) except requests.Timeout: exit_status = ExitStatus.ERROR_TIMEOUT env.log_error(f'Request timed out ({parsed_args.timeout}s).')