Skip to content

Commit

Permalink
Added BoxDynError support
Browse files Browse the repository at this point in the history
  • Loading branch information
markcda committed Jun 13, 2024
1 parent 6aa4e79 commit 1b0cdad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cc-utils"
description = "Rust Fullstack utils (strict error handling, `Consider` trait, MessagePack support, etc.) for Salvo and Yew/Dioxus/Leptos/*"
version = "0.2.12"
version = "0.2.13"
edition = "2021"
license = "MIT"
authors = ["Klimenty Titov <[email protected]>"]
Expand Down
8 changes: 7 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use salvo::{Depot, Request, Response};
#[cfg(feature = "salvo")]
use salvo::Writer as ServerResponseWriter;

pub type BoxDynError = Box<dyn std::error::Error + 'static + Send + Sync>;

/// Data structure responsible for server errors.
#[cfg(feature = "salvo")]
#[derive(Debug)]
Expand Down Expand Up @@ -509,6 +511,8 @@ impl_consider!(std::sync::mpsc::RecvError);
impl_consider!(log::SetLoggerError);
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
impl_consider!(serde_json::Error);
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
impl_consider!(BoxDynError);

#[cfg(feature = "salvo")]
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
Expand Down Expand Up @@ -552,7 +556,7 @@ impl<T> Consider<T> for Result<T, Option<&Box<dyn Any + Send + Sync>>> {
#[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))]
impl From<Option<&Box<dyn Any + Send + Sync>>> for ErrorResponse {
/// Создаёт `ErrorResponse` из данной ошибки.
fn from(_value: Option<&Box<(dyn std::any::Any + Send + Sync + 'static)>>) -> Self {
fn from(_value: Option<&Box<(dyn Any + Send + Sync + 'static)>>) -> Self {
"Depot obtain failed!".into()
}
}
Expand Down Expand Up @@ -658,6 +662,8 @@ impl_consider_cli!(std::io::Error);
impl_consider_cli!(log::SetLoggerError);
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))]
impl_consider_cli!(serde_json::Error);
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))]
impl_consider_cli!(BoxDynError);

#[cfg(feature = "reqwest")]
#[cfg(any(target_arch = "wasm32", target_arch = "wasm64"))]
Expand Down

0 comments on commit 1b0cdad

Please sign in to comment.