Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/generated_schema/2024_11_05/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,14 +1465,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}" ),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

// Format the full error message
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}");

Self::from_message(full_message)
}

Expand Down Expand Up @@ -1513,7 +1521,6 @@ impl CallToolError {
}
}


/// Converts a `CallToolError` into a `RpcError`.
///
/// The conversion creates an internal error variant of `RpcError`
Expand Down
25 changes: 16 additions & 9 deletions src/generated_schema/2025_03_26/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,14 +1465,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}" ),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

// Format the full error message
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}");

Self::from_message(full_message)
}

Expand Down Expand Up @@ -1513,7 +1521,6 @@ impl CallToolError {
}
}


/// Converts a `CallToolError` into a `RpcError`.
///
/// The conversion creates an internal error variant of `RpcError`
Expand Down
24 changes: 16 additions & 8 deletions src/generated_schema/2025_06_18/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1466,14 +1466,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}"),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

// Format the full error message
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}");

Self::from_message(full_message)
}

Expand Down
24 changes: 16 additions & 8 deletions src/generated_schema/draft/schema_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,14 +1468,22 @@ impl CallToolError {
CallToolError(Box::new(UnknownTool(tool_name.into())))
}

pub fn invalid_arguments(tool_name: impl Into<String>, message: Option<impl Into<String>>) -> Self {
let tool_name = tool_name.into();
let message = message.map(|m| m.into());

let full_message = match message {
Some(msg) => format!("Invalid arguments for tool '{tool_name}': {msg}"),
None => format!("Invalid arguments for tool '{tool_name}'"),
};
/// Creates a `CallToolError` for invalid arguments with optional details.
///
pub fn invalid_arguments(tool_name: impl AsRef<str>, message: Option<String>) -> Self {
// Trim tool_name to remove whitespace and check for emptiness
let tool_name = tool_name.as_ref().trim();
if tool_name.is_empty() {
return Self::from_message("Invalid arguments: tool name cannot be empty".to_string());
}

// Use a descriptive default message if none provided
let default_message = "no additional details provided".to_string();
let message = message.unwrap_or(default_message);

// Format the full error message
let full_message = format!("Invalid arguments for tool '{tool_name}': {message}");

Self::from_message(full_message)
}

Expand Down