Skip to content

Commit

Permalink
refactor: Handle specific code graph errors to not break code
Browse files Browse the repository at this point in the history
  • Loading branch information
dexters1 committed Jan 31, 2025
1 parent 04f50e3 commit 7351898
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cognee/tasks/repo_processor/get_local_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
from contextlib import contextmanager
from pathlib import Path
from pickle import UnpicklingError
from typing import List, Dict, Optional

import aiofiles
Expand Down Expand Up @@ -60,6 +61,18 @@ def _update_code_entity(script: jedi.Script, code_entity: Dict[str, any]) -> Non
code_entity["full_name"] = getattr(result, "full_name", None)
code_entity["module_name"] = getattr(result, "module_name", None)
code_entity["module_path"] = getattr(result, "module_path", None)
except KeyError as e:
# TODO: See if there is a way to handle KeyError properly
logger.error(f"Failed to analyze code entity {code_entity['name']}: {e}")
return
except UnpicklingError as e:
# TODO: See if there is a way to handle UnpicklingError properly
logger.error(f"Failed to analyze code entity {code_entity['name']}: {e}")
return
except EOFError as e:
# TODO: See if there is a way to handle EOFError properly
logger.error(f"Failed to analyze code entity {code_entity['name']}: {e}")
return
except Exception as e:
# logging.warning(f"Failed to analyze code entity {code_entity['name']}: {e}")
logger.error(f"Failed to analyze code entity {code_entity['name']}: {e}")
Expand Down

0 comments on commit 7351898

Please sign in to comment.