From 3fea134d86a3bf412c595fa62f151e2505f90f51 Mon Sep 17 00:00:00 2001 From: FoolFu <162613064+FoolFu@users.noreply.github.com> Date: Sat, 22 Nov 2025 00:35:46 +0800 Subject: [PATCH] Refine error handling for LLM factories config Improve exception handling to provide more specific and detailed error handling, aiding debugging and troubleshooting. --- common/settings.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/settings.py b/common/settings.py index ac2b13e00e6..88628a12e4b 100644 --- a/common/settings.py +++ b/common/settings.py @@ -179,7 +179,17 @@ def init_settings(): try: with open(os.path.join(get_project_base_directory(), "conf", "llm_factories.json"), "r") as f: FACTORY_LLM_INFOS = json.load(f)["factory_llm_infos"] - except Exception: + except FileNotFoundError: + logging.warning(f"LLM factories config not found at {config_path}") + FACTORY_LLM_INFOS = [] + except KeyError: + logging.warning("Invalid LLM factories config format") + FACTORY_LLM_INFOS = [] + except json.JSONDecodeError: + logging.error("Invalid JSON in LLM factories config") + FACTORY_LLM_INFOS = [] + except Exception as e: + logging.error(f"Unexpected error loading LLM factories config: {e}") FACTORY_LLM_INFOS = [] global API_KEY