Skip to content

Commit 257a3c9

Browse files
changed errors into graceful comments
1 parent 9b64374 commit 257a3c9

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/codegraphcontext/server.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,11 @@ def watch_directory_tool(self, **args) -> Dict[str, Any]:
502502

503503
# 1. Validate the path before the try...except block
504504
if not path_obj.is_dir():
505-
return {"error": f"Invalid path provided: '{path_str}'. Path must be an existing directory."}
506-
505+
return {
506+
"success": True,
507+
"status": "path_not_found",
508+
"message": f"Path '{path_str}' does not exist or is not a directory."
509+
}
507510
try:
508511
# Check if already watching
509512
if path_str in self.code_watcher.watched_paths:
@@ -601,7 +604,11 @@ def add_code_to_graph_tool(self, **args) -> Dict[str, Any]:
601604
path_obj = Path(path).resolve()
602605

603606
if not path_obj.exists():
604-
return {"error": f"Path {path} does not exist"}
607+
return {
608+
"success": True,
609+
"status": "path_not_found",
610+
"message": f"Path '{path}' does not exist."
611+
}
605612

606613
# Prevent re-indexing the same repository.
607614
indexed_repos = self.list_indexed_repositories_tool().get("repositories", [])
@@ -693,12 +700,18 @@ def add_package_to_graph_tool(self, **args) -> Dict[str, Any]:
693700
def check_job_status_tool(self, **args) -> Dict[str, Any]:
694701
"""Tool to check job status"""
695702
job_id = args.get("job_id")
703+
if not job_id:
704+
return {"error": "Job ID is a required argument."}
696705

697706
try:
698707
job = self.job_manager.get_job(job_id)
699708

700709
if not job:
701-
return {"error": f"Job {job_id} not found"}
710+
return {
711+
"success": True, # Return success to avoid generic error wrapper
712+
"status": "not_found",
713+
"message": f"Job with ID '{job_id}' not found. The ID may be incorrect or the job may have been cleared after a server restart."
714+
}
702715

703716
job_dict = asdict(job)
704717

0 commit comments

Comments
 (0)