diff --git a/src/writer/__init__.py b/src/writer/__init__.py index 8e071404a..29fb3548e 100644 --- a/src/writer/__init__.py +++ b/src/writer/__init__.py @@ -37,11 +37,9 @@ ) PROPER_UI_INIT = False -def _raise_ui_runtime_error(): - raise RuntimeError( - "UI module is unavailable – Writer Framework is not properly built. " + +def _get_ui_runtime_error_message() -> str: + return "UI module is unavailable – Writer Framework is not properly built. " + \ "Please refer to CONTRIBUTING.md for instructions to resolve this issue." - ) VERSION = importlib.metadata.version("writer") @@ -96,7 +94,7 @@ def init_ui() -> WriterUIManager: if PROPER_UI_INIT: return WriterUIManager() else: - _raise_ui_runtime_error() + raise RuntimeError(_get_ui_runtime_error_message()) def init_state(raw_state: Dict[str, Any], schema: Optional[Type[S]] = None) -> Union[S, WriterState]: diff --git a/src/writer/core.py b/src/writer/core.py index ae5d6e95b..5e78557e9 100644 --- a/src/writer/core.py +++ b/src/writer/core.py @@ -2529,12 +2529,12 @@ def _event_handler_session_info() -> Dict[str, Any]: return session_info def _event_handler_ui_manager(): - from writer import PROPER_UI_INIT, _raise_ui_runtime_error + from writer import PROPER_UI_INIT, _get_ui_runtime_error_message if PROPER_UI_INIT: from writer.ui import WriterUIManager return WriterUIManager() else: - _raise_ui_runtime_error() + raise RuntimeError(_get_ui_runtime_error_message()) def _split_record_as_pandas_record_and_index(param: dict, index_columns: list) -> Tuple[dict, tuple]: