Skip to content

Commit 89ebb3d

Browse files
committed
Switch to eyre
1 parent 686acee commit 89ebb3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+168
-84
lines changed

Cargo.lock

Lines changed: 68 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ serenity = { version = "0.12.4", default-features = false, features = [
2626
poise = "0.6.1"
2727

2828

29-
anyhow = "1.0.82"
29+
eyre = "0.6.12"
30+
color-eyre = "0.6.5"
31+
tracing-error = "0.2.1"
3032
chrono = "0.4.38"
3133
chrono-humanize = "0.2.3"
3234
itertools = "0.14.0"

crates/robbb/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ edition = "2018"
66

77

88
[dependencies]
9+
tracing-error.workspace = true
10+
eyre.workspace = true
11+
color-eyre.workspace = true
912
serenity.workspace = true
1013
poise.workspace = true
11-
anyhow.workspace = true
1214
chrono.workspace = true
1315
chrono-humanize.workspace = true
1416
itertools.workspace = true
@@ -20,7 +22,7 @@ thiserror.workspace = true
2022
serde_json.workspace = true
2123
serde.workspace = true
2224
maplit.workspace = true
23-
byte-unit = { version = "5.1.4", features = ["u128"] }
25+
byte-unit = { workspace = true, features = ["u128"] }
2426
url.workspace = true
2527
regex.workspace = true
2628
reqwest = { workspace = true }

crates/robbb/src/attachment_logging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{Context, Result};
1+
use eyre::{Context, Result};
22
use robbb_util::config::Config;
33
use std::{
44
os::unix::prelude::MetadataExt,

crates/robbb/src/error_handling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async fn handle_argument_parse_error(
152152
ctx: Ctx<'_>,
153153
error: Box<dyn std::error::Error + Send + Sync>,
154154
input: Option<String>,
155-
) -> anyhow::Result<()> {
155+
) -> eyre::Result<()> {
156156
let msg = if error.downcast_ref::<humantime::DurationError>().is_some() {
157157
format!("'{}' is not a valid duration", input.unwrap_or_default())
158158
} else if error.downcast_ref::<UserParseError>().is_some() {

crates/robbb/src/events/auto_moderation_action.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use robbb_util::extensions::ClientContextExt;
22
use serenity::{all::ActionExecution, client};
33

4-
pub async fn execution(ctx: client::Context, execution: ActionExecution) -> anyhow::Result<()> {
4+
pub async fn execution(ctx: client::Context, execution: ActionExecution) -> eyre::Result<()> {
55
tracing::info!(
66
execution.action = ?execution.action,
77
execution = ?execution,

crates/robbb/src/events/guild_audit_log_entry_create.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use serenity::{
88
pub async fn guild_audit_log_entry_create(
99
ctx: client::Context,
1010
entry: AuditLogEntry,
11-
) -> anyhow::Result<()> {
11+
) -> eyre::Result<()> {
1212
tracing::info!(
1313
auditlog.entry.id = %entry.id,
1414
auditlog.entry.action = ?entry.action,

crates/robbb/src/events/message_create.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::collections::HashSet;
22

33
use chrono::Utc;
4+
use eyre::ContextCompat as _;
45
use itertools::Itertools;
56
use maplit::hashmap;
67
use poise::serenity_prelude::{MessageType, ReactionType};
@@ -28,12 +29,14 @@ pub async fn message_create(ctx: client::Context, msg: Message) -> Result<bool>
2829
return Ok(true);
2930
}
3031

32+
let channel_name = msg.channel_id.name(&ctx).await?;
33+
3134
tracing::debug!(
3235
msg.content = %msg.content,
3336
msg.author = %msg.author.tag(),
3437
msg.author_id = %msg.author.id,
3538
msg.id = %msg.id,
36-
msg.channel = %msg.channel_id.name_cached_or_fallback(&ctx.cache),
39+
msg.channel = %channel_name,
3740
msg.channel_id = %msg.channel_id,
3841
"new message from {}: {}",
3942
msg.author.tag(),

crates/robbb/src/events/message_delete.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use eyre::ContextCompat as _;
12
use futures::StreamExt;
23
use itertools::Itertools;
34
use poise::serenity_prelude::{AuditLogEntry, MessageAction};

crates/robbb/src/events/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22
use std::sync::Arc;
33

4-
use anyhow::{Context, Result};
4+
use eyre::{Context, Result};
55

66
use poise::async_trait;
77
use poise::serenity_prelude::{

0 commit comments

Comments
 (0)