Merge PR #617: Improve skills tool error handling
Authored by aydnOktay. Adds logging to skills_tool.py with specific exception handling for file read errors (UnicodeDecodeError, PermissionError) vs unexpected exceptions, replacing bare except-and-continue blocks.
This commit is contained in:
commit
d723208b1b
1 changed files with 13 additions and 2 deletions
|
|
@ -63,6 +63,7 @@ Usage:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -71,6 +72,8 @@ from typing import Dict, Any, List, Optional, Tuple
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# All skills live in ~/.hermes/skills/ (seeded from bundled skills/ on install).
|
# All skills live in ~/.hermes/skills/ (seeded from bundled skills/ on install).
|
||||||
# This is the single source of truth -- agent edits, hub installs, and bundled
|
# This is the single source of truth -- agent edits, hub installs, and bundled
|
||||||
|
|
@ -269,7 +272,11 @@ def _find_all_skills() -> List[Dict[str, Any]]:
|
||||||
"category": category,
|
"category": category,
|
||||||
})
|
})
|
||||||
|
|
||||||
except Exception:
|
except (UnicodeDecodeError, PermissionError) as e:
|
||||||
|
logger.warning("Failed to read skill file %s: %s", skill_md, e)
|
||||||
|
continue
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning("Error parsing skill %s: %s", skill_md, e, exc_info=True)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return skills
|
return skills
|
||||||
|
|
@ -308,7 +315,11 @@ def _load_category_description(category_dir: Path) -> Optional[str]:
|
||||||
description = description[:MAX_DESCRIPTION_LENGTH - 3] + "..."
|
description = description[:MAX_DESCRIPTION_LENGTH - 3] + "..."
|
||||||
|
|
||||||
return description if description else None
|
return description if description else None
|
||||||
except Exception:
|
except (UnicodeDecodeError, PermissionError) as e:
|
||||||
|
logger.debug("Failed to read category description %s: %s", desc_file, e)
|
||||||
|
return None
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning("Error parsing category description %s: %s", desc_file, e, exc_info=True)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue