mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-16 12:43:01 -04:00
Add eyre feature to matrix-sdk
This commit is contained in:
@@ -38,6 +38,7 @@ anyhow = { version = "1.0.42", optional = true }
|
||||
bytes = "1.0.1"
|
||||
dashmap = "4.0.2"
|
||||
event-listener = "2.5.1"
|
||||
eyre = { version = "0.6.5", optional = true }
|
||||
futures = "0.3.15"
|
||||
http = "0.2.4"
|
||||
matrix-sdk-common = { version = "0.4.0", path = "../matrix-sdk-common" }
|
||||
|
||||
@@ -62,6 +62,8 @@ The following crate feature flags are available:
|
||||
high-level API there's the `matrix-sdk-appservice` crate
|
||||
* `anyhow`: More verbose error logging for event handlers that return
|
||||
`anyhow::Result<()>`.
|
||||
* `eyre`: More verbose error logging for event handlers that return
|
||||
`eyre::Result<()>`.
|
||||
|
||||
# Enabling logging
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
//!
|
||||
//! For more details, see the [`EventHandler`] trait.
|
||||
|
||||
#[cfg(feature = "anyhow")]
|
||||
#[cfg(any(feature = "anyhow", feature = "eyre"))]
|
||||
use std::any::TypeId;
|
||||
use std::{borrow::Cow, fmt, future::Future, ops::Deref};
|
||||
|
||||
@@ -70,8 +70,9 @@ pub trait SyncEvent {
|
||||
/// that implements [`SyncEvent`]. Any additional arguments need to implement
|
||||
/// the [`EventHandlerContext`] trait.
|
||||
/// * Their return type has to be one of: `()`, `Result<(), impl Display + Debug
|
||||
/// + 'static>` (if you are using `anyhow::Result` you can additionally enable
|
||||
/// the `anyhow` feature to get the verbose `Debug` output printed on error)
|
||||
/// + 'static>` (if you are using `anyhow::Result` or `eyre::Result` you can
|
||||
/// additionally enable the `anyhow` / `eyre` feature to get the verbose
|
||||
/// `Debug` output printed on error)
|
||||
///
|
||||
/// ### How it works
|
||||
///
|
||||
@@ -197,6 +198,10 @@ impl<E: fmt::Debug + fmt::Display + 'static> EventHandlerResult for Result<(), E
|
||||
Err(e) if TypeId::of::<E>() == TypeId::of::<anyhow::Error>() => {
|
||||
tracing::error!("Event handler for `{}` failed: {:?}", event_type, e);
|
||||
}
|
||||
#[cfg(feature = "eyre")]
|
||||
Err(e) if TypeId::of::<E>() == TypeId::of::<eyre::Report>() => {
|
||||
tracing::error!("Event handler for `{}` failed: {:?}", event_type, e);
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::error!("Event handler for `{}` failed: {}", event_type, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user