refactor: ok_or_else() -> ok_or_eyre()

This commit is contained in:
seth 2024-01-27 23:33:00 -05:00
parent fafa0bf689
commit f4fa737124
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
10 changed files with 23 additions and 29 deletions

View file

@ -1,6 +1,6 @@
use crate::api::REQWEST_CLIENT;
use eyre::{eyre, Result};
use eyre::{eyre, OptionExt, Result};
use once_cell::sync::Lazy;
use regex::Regex;
use reqwest::StatusCode;
@ -48,7 +48,7 @@ pub async fn find(content: &str) -> Result<Option<String>> {
let paste_files: PasteResponse = resp.json().await?;
let file_id = &paste_files
.result
.ok_or_else(|| eyre!("Couldn't find any files associated with paste {paste_id}!"))?[0]
.ok_or_eyre("Couldn't find any files associated with paste {paste_id}!")?[0]
.id;
let raw_url = format!("{PASTE_GG}{PASTES_ENDPOINT}/{paste_id}/files/{file_id}/raw");

View file

@ -5,12 +5,12 @@ pub async fn handle(ctx: &Context, reaction: &Reaction) -> Result<()> {
let user = reaction
.user(ctx)
.await
.wrap_err_with(|| "Couldn't fetch user from reaction!")?;
.wrap_err("Couldn't fetch user from reaction!")?;
let message = reaction
.message(ctx)
.await
.wrap_err_with(|| "Couldn't fetch message from reaction!")?;
.wrap_err("Couldn't fetch message from reaction!")?;
if let Some(interaction) = &message.interaction {
if interaction.kind == InteractionType::Command

View file

@ -1,4 +1,4 @@
use eyre::{eyre, Result};
use eyre::{eyre, OptionExt, Result};
use log::debug;
use poise::serenity_prelude::{
ChannelType, Context, CreateAllowedMentions, CreateMessage, GuildChannel,
@ -24,7 +24,7 @@ pub async fn handle(ctx: &Context, thread: &GuildChannel) -> Result<()> {
let owner = thread
.owner_id
.ok_or_else(|| eyre!("Couldn't get owner of thread!"))?;
.ok_or_eyre("Couldn't get owner of thread!")?;
let msg = format!(
"<@{}> We've received your support ticket! {} {}",