Skip to content

Commit c552cc9

Browse files
committed
chore: update for 11-05
1 parent ba33bde commit c552cc9

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/generated_schema/2024_11_05/schema_utils.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,14 +1465,22 @@ impl CallToolError {
14651465
CallToolError(Box::new(UnknownTool(tool_name.into())))
14661466
}
14671467

1468-
pub fn invalid_arguments<M: Into<String>>(tool_name: M, message: Option<M>) -> Self {
1469-
let tool_name = tool_name.into();
1470-
let message = message.map(|m| m.into());
1471-
1472-
let full_message = match message {
1473-
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}"),
1474-
None => format!("Invalid arguments for tool '{tool_name}'"),
1475-
};
1468+
/// Creates a `CallToolError` for invalid arguments with optional details.
1469+
///
1470+
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
1471+
// Trim tool_name to remove whitespace and check for emptiness
1472+
let tool_name = tool_name.as_ref().trim();
1473+
if tool_name.is_empty() {
1474+
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
1475+
}
1476+
1477+
// Use a descriptive default message if none provided
1478+
let default_message = "no additional details provided".to_string();
1479+
let message = message.unwrap_or(default_message);
1480+
1481+
// Format the full error message
1482+
let full_message = format!("Invalid arguments for tool '{}': {}", tool_name, message);
1483+
14761484
Self::from_message(full_message)
14771485
}
14781486

0 commit comments

Comments
 (0)