You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seeing if I can replace thiserror with derive_more:
use derive_more::{Display,Error,From};#[derive(Debug,Display,Error,From)]enumError{SomeError(#[from] std::io::Error),SomeOtherError(Box<dynError + Send + Sync + 'static>),}// Perform type-erasure so that `tracing_subscriber` dependency is not leaked to clientsimplFrom<tracing_subscriber::util::TryInitError>forError{fnfrom(error: tracing_subscriber::util::TryInitError) -> Self{Self::SomeOtherError(Box::new(error))}}
gives a compilation error (conflicting From impls), whereas thiserror has no problem with this:
use thiserror::Error;#[derive(Debug,Error)]enumError{#[error("SomeError occurred.")]SomeError(#[from] std::io::Error),#[error(transparent)]SomeOtherError(Box<dynError + Send + Sync + 'static>),}// Perform type-erasure so that `tracing_subscriber` dependency is not leaked to clientsimplFrom<tracing_subscriber::util::TryInitError>forError{fnfrom(error: tracing_subscriber::util::TryInitError) -> Self{Self::SomeOtherError(Box::new(error))}}
compiles fine.
The text was updated successfully, but these errors were encountered:
If I change @U007D his example to use use derive_more::derive::{Display, Error, From} instead of use derive_more::{Display, Error, From}, then it compiles fine for me (after also changing dyn Error to dyn std::error::Error.
@U007D if that doesn't fix your issue could you give an example that fails in the way you are describing?
Seeing if I can replace
thiserror
withderive_more
:gives a compilation error (conflicting
From
impls), whereasthiserror
has no problem with this:compiles fine.
The text was updated successfully, but these errors were encountered: