From 37dea8cb5d6adc9a4251949ea78a9b14620921ff Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Fri, 23 Apr 2021 17:16:08 -0700 Subject: [PATCH] Use central exceptions. --- input_utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/input_utils.py b/input_utils.py index b19bfe1..648ee30 100644 --- a/input_utils.py +++ b/input_utils.py @@ -7,6 +7,8 @@ import signal import sys from typing import List +import exceptions + def single_keystroke_response( valid_responses: List[str], @@ -15,11 +17,8 @@ def single_keystroke_response( default_response: str = None, timeout_seconds: int = None, ) -> str: - class TimeoutError(Exception): - pass - def _handle_timeout(signum, frame) -> None: - raise TimeoutError() + raise exceptions.TimeoutError() def _single_keystroke_response_internal( valid_responses: List[str], timeout_seconds=None @@ -48,7 +47,7 @@ def single_keystroke_response( response = _single_keystroke_response_internal( valid_responses, timeout_seconds ) - except TimeoutError: + except exceptions.TimeoutError: if default_response is not None: response = default_response if prompt is not None: -- 2.46.0