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
4 changes: 2 additions & 2 deletions crates/aether-lspd/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ impl LspDaemon {
create_dir_all(parent).map_err(DaemonError::Io)?;
}

let _lockfile = PidLockfile::acquire(&self.socket_path.with_extension("lock"))
.map_err(|e| DaemonError::LockfileError(e.to_string()))?;
let _lockfile =
PidLockfile::acquire(&self.socket_path.with_extension("lock")).map_err(DaemonError::LockfileError)?;

let _ = remove_file(&self.socket_path);

Expand Down
2 changes: 1 addition & 1 deletion crates/aether-lspd/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum DaemonError {

/// Lockfile error
#[error("Lockfile error: {0}")]
LockfileError(String),
LockfileError(#[source] io::Error),
}

/// Result type for daemon operations
Expand Down
7 changes: 3 additions & 4 deletions crates/aether-project/src/prompt_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl PromptFile {
harmful: self.harmful,
};

let yaml = serde_yml::to_string(&frontmatter).map_err(|e| PromptFileError::Yaml(e.to_string()))?;
let yaml = serde_yml::to_string(&frontmatter)?;
let yaml = normalize_frontmatter_yaml(&yaml);

let file_content = if self.body.is_empty() {
Expand All @@ -169,8 +169,7 @@ impl PromptFile {
let (yaml_str, body) =
utils::markdown_file::split_frontmatter(content).ok_or(PromptFileError::MissingFrontmatter)?;

let frontmatter: PromptFrontmatter =
serde_yml::from_str(yaml_str).map_err(|e| PromptFileError::Yaml(e.to_string()))?;
let frontmatter: PromptFrontmatter = serde_yml::from_str(yaml_str)?;

Ok((frontmatter, body.to_string()))
}
Expand Down Expand Up @@ -223,7 +222,7 @@ pub enum PromptFileError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("YAML error: {0}")]
Yaml(String),
Yaml(#[from] serde_yml::Error),
#[error("missing YAML frontmatter")]
MissingFrontmatter,
#[error("skill '{name}' has an empty description")]
Expand Down
17 changes: 9 additions & 8 deletions crates/mcp-servers/src/coding/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//! This module provides structured error types for all coding tool operations,
//! replacing the previous `Result<T, String>` pattern with proper `thiserror` enums.

use std::io;
use thiserror::Error;

pub use crate::file_ops::FileError;
Expand Down Expand Up @@ -64,11 +65,11 @@ pub enum BashError {

/// Invalid regex pattern for filtering
#[error("Invalid regex pattern: {0}")]
InvalidRegex(String),
InvalidRegex(#[source] regex::Error),

/// Failed to join background task
#[error("Failed to join background task: {0}")]
JoinFailed(String),
JoinFailed(#[source] tokio::task::JoinError),

/// Shell ID not found
#[error("Shell ID not found: {0}")]
Expand All @@ -88,7 +89,7 @@ pub enum GlobError {

/// Failed to build glob set
#[error("Failed to build glob set: {0}")]
BuildFailed(String),
BuildFailed(#[source] globset::Error),
}

/// Errors related to grep search operations
Expand All @@ -100,7 +101,7 @@ pub enum GrepError {

/// Invalid regex pattern
#[error("Invalid regex pattern: {0}")]
InvalidRegex(String),
InvalidRegex(#[source] grep::regex::Error),

/// Search error during file processing
#[error("Search error: {0}")]
Expand Down Expand Up @@ -164,23 +165,23 @@ pub enum FindError {
pub enum ListFilesError {
/// Failed to read directory
#[error("Failed to read directory: {0}")]
ReadDirFailed(String),
ReadDirFailed(#[source] io::Error),

/// Failed to read directory entry
#[error("Failed to read entry: {0}")]
ReadEntryFailed(String),
ReadEntryFailed(#[source] io::Error),

/// Failed to read metadata
#[error("Failed to read metadata: {0}")]
MetadataFailed(String),
MetadataFailed(#[source] io::Error),
}

/// Errors related to web fetch operations
#[derive(Debug, Error)]
pub enum WebFetchError {
/// Invalid URL format
#[error("Invalid URL: {0}")]
InvalidUrl(String),
InvalidUrl(#[source] url::ParseError),

/// HTTP request failed
#[error("Request failed: {0}")]
Expand Down
4 changes: 2 additions & 2 deletions crates/mcp-servers/src/coding/tools/bash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub async fn read_background_bash(
// Collect all available output
let mut output = String::new();
let filter_regex = if let Some(pattern) = filter {
Some(regex::Regex::new(&pattern).map_err(|e| BashError::InvalidRegex(e.to_string()))?)
Some(regex::Regex::new(&pattern).map_err(BashError::InvalidRegex)?)
} else {
None
};
Expand All @@ -114,7 +114,7 @@ pub async fn read_background_bash(
}

if task_handle.is_finished() {
let (exit_code, killed) = task_handle.await.map_err(|e| BashError::JoinFailed(e.to_string()))?;
let (exit_code, killed) = task_handle.await.map_err(BashError::JoinFailed)?;

let status = if killed { BackgroundShellStatus::Failed } else { BackgroundShellStatus::Completed };

Expand Down
2 changes: 1 addition & 1 deletion crates/mcp-servers/src/coding/tools/glob_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl PathGlobMatcher {
add_glob(&mut builder, root_pattern, case_sensitivity)?;
}

Ok(Self { matcher: builder.build().map_err(|e| GlobError::BuildFailed(e.to_string()))?, kind })
Ok(Self { matcher: builder.build().map_err(GlobError::BuildFailed)?, kind })
}

pub fn matches(&self, path: &Path, search_root: &Path) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion crates/mcp-servers/src/coding/tools/grep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ fn build_matcher(
matcher_builder.multi_line(true).dot_matches_new_line(true);
}

matcher_builder.build(pattern).map_err(|e| GrepError::InvalidRegex(e.to_string()))
matcher_builder.build(pattern).map_err(GrepError::InvalidRegex)
}

fn build_searcher(args: &GrepInput) -> SearcherBuilder {
Expand Down
9 changes: 4 additions & 5 deletions crates/mcp-servers/src/coding/tools/list_files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ pub async fn list_files(args: ListFilesArgs) -> Result<ListFilesResult, ListFile
let mut files = Vec::new();

// Read directory entries
let mut entries =
tokio::fs::read_dir(target_path).await.map_err(|e| ListFilesError::ReadDirFailed(e.to_string()))?;
let mut entries = tokio::fs::read_dir(target_path).await.map_err(ListFilesError::ReadDirFailed)?;

while let Some(entry) = entries.next_entry().await.map_err(|e| ListFilesError::ReadEntryFailed(e.to_string()))? {
while let Some(entry) = entries.next_entry().await.map_err(ListFilesError::ReadEntryFailed)? {
let path = entry.path();
let entry_file_type = entry.file_type().await.map_err(|e| ListFilesError::MetadataFailed(e.to_string()))?;
let metadata = entry.metadata().await.map_err(|e| ListFilesError::MetadataFailed(e.to_string()))?;
let entry_file_type = entry.file_type().await.map_err(ListFilesError::MetadataFailed)?;
let metadata = entry.metadata().await.map_err(ListFilesError::MetadataFailed)?;

let name = entry.file_name().to_string_lossy().to_string();

Expand Down
2 changes: 1 addition & 1 deletion crates/mcp-servers/src/coding/tools/web_fetch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn normalize_url(url: &str) -> Result<String, WebFetchError> {
url.to_string()
};

Url::parse(&url).map(|u| u.to_string()).map_err(|e| WebFetchError::InvalidUrl(e.to_string()))
Url::parse(&url).map(|u| u.to_string()).map_err(WebFetchError::InvalidUrl)
}

fn extract_title(html: &str) -> Option<String> {
Expand Down