Refactor error handling to use anyhow throughout codebase

Switch all custom error types and handler signatures from `Box<dyn
std::error::Error + Send + Sync>` to `anyhow::Result`. Add anyhow as a
dependency. Fix typos and update function names for consistency.
This commit is contained in:
2025-06-22 16:26:27 +02:00
parent 39ff5f01e7
commit 2f33b41359
16 changed files with 74 additions and 109 deletions

View File

@@ -39,7 +39,7 @@ async fn send_book_handler<T, P, Fut>(
where
T: Format + Clone + Debug,
P: FormatTitle + Clone + Debug,
Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>,
Fut: std::future::Future<Output = anyhow::Result<Page<T, P>>>,
{
let id = match command {
BookCommand::Author { id } => id,
@@ -59,7 +59,7 @@ where
.await
{
Ok(_) => Ok(()),
Err(err) => Err(Box::new(err)),
Err(err) => Err(err.into()),
}
}
};
@@ -110,7 +110,7 @@ async fn send_pagination_book_handler<T, P, Fut>(
where
T: Format + Clone + Debug,
P: FormatTitle + Clone + Debug,
Fut: std::future::Future<Output = Result<Page<T, P>, Box<dyn std::error::Error + Send + Sync>>>,
Fut: std::future::Future<Output = anyhow::Result<Page<T, P>>>,
{
let (id, page) = match callback_data {
BookCallbackData::Author { id, page } => (id, page),