Fix error swallowing by propagating JSON serialization errors to LLM
This commit is contained in:
1 parent
48a1973ea6
commit
01d3c22c57
6 files changed
+59
-59
No files matched your search
@@ -89,9 +89,9 @@ impl McpTool for ListPinnedFilesHandler {
|
||||
ns_match && branch_match
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_string(&filtered).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,9 +154,9 @@ impl McpTool for SearchSnippetsHandler {
|
||||
|| contains_ignore_ascii_case(&s.language, &query)
|
||||
})
|
||||
.collect();
|
||||
serde_json::to_string(&results).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&results).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,9 +245,9 @@ impl McpTool for LoadContextWorkspaceHandler {
|
||||
.iter()
|
||||
.filter(|w| w.namespace == req.namespace && w.name == req.name)
|
||||
.collect();
|
||||
serde_json::to_string(&filtered.first()).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&filtered.first()).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,9 +271,9 @@ impl McpTool for ListContextWorkspacesHandler {
|
||||
serde_json::from_value(args).map_err(|e| e.to_string())?;
|
||||
let data = state.context_workspaces.read_with(|ws| {
|
||||
let filtered: Vec<_> = ws.iter().filter(|w| req.namespace.as_ref().map_or(true, |ns| &w.namespace == ns)).collect();
|
||||
serde_json::to_string(&filtered).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,9 +325,9 @@ impl McpTool for GetPrChecklistHandler {
|
||||
.iter()
|
||||
.filter(|i| i.namespace == req.namespace)
|
||||
.collect();
|
||||
serde_json::to_string(&filtered).unwrap_or_default()
|
||||
});
|
||||
Ok(data.to_string())
|
||||
serde_json::to_string(&filtered).map_err(|e| e.to_string())
|
||||
})?;
|
||||
Ok(data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user