Adding error logging when config file is not found. (#11419)

Co-authored-by: jarrycyx <dzdzzd@126.com>
Co-authored-by: Engel Nyst <engel.nyst@gmail.com>
This commit is contained in:
Yuxiao Cheng 2025-11-04 02:19:48 +08:00 committed by GitHub
parent 2a98cd9338
commit 9bcf80dba5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,7 +148,10 @@ def load_from_toml(cfg: OpenHandsConfig, toml_file: str = 'config.toml') -> None
try:
with open(toml_file, 'r', encoding='utf-8') as toml_contents:
toml_config = toml.load(toml_contents)
except FileNotFoundError:
except FileNotFoundError as e:
logger.openhands_logger.error(
f'{toml_file} not found: {e}. Toml values have not been applied.'
)
return
except toml.TomlDecodeError as e:
logger.openhands_logger.warning(
@ -601,7 +604,10 @@ def get_llms_for_routing_config(toml_file: str = 'config.toml') -> dict[str, LLM
try:
with open(toml_file, 'r', encoding='utf-8') as toml_contents:
toml_config = toml.load(toml_contents)
except FileNotFoundError:
except FileNotFoundError as e:
logger.openhands_logger.error(
f'Config file not found: {e}. Toml values have not been applied.'
)
return llms_for_routing
except toml.TomlDecodeError as e:
logger.openhands_logger.error(