| Crates.io | poise_error |
| lib.rs | poise_error |
| version | 1.6.0 |
| created_at | 2025-01-21 23:07:51.371369+00 |
| updated_at | 2025-07-27 21:27:28.632055+00 |
| description | An opinionated plug-and-play library for error handling in Discord bots made with poise. |
| homepage | |
| repository | https://github.com/valentinegb/poise-error |
| max_upload_size | |
| id | 1525901 |
| size | 77,788 |
poise_errorAn opinionated plug-and-play library for error handling in Discord bots made
with poise.
To get started, plug poise_error::on_error into your poise::FrameworkOptions
to let poise_error handle your bot's errors.
use poise_error::on_error;
let framework = poise::Framework::builder()
.options(poise::FrameworkOptions {
on_error,
..Default::default()
})
.build();
See the docs for more information.
Goober Bot is a Discord bot which uses poise_error, here's how it looks:
use poise::{ChoiceParameter, command};
use poise_error::{
UserError,
anyhow::{self, anyhow, bail},
};
#[derive(ChoiceParameter)]
enum ErrorKind {
User,
Internal,
Panic,
}
/// Fails intentionally
#[command(slash_command)]
async fn error(
_ctx: poise_error::Context<'_>,
#[description = "Kind of error to return"] kind: ErrorKind,
) -> anyhow::Result<()> {
match kind {
ErrorKind::User => bail!(UserError(
anyhow!("This is an example of a user error")
.context("This is an example of extra context")
)),
ErrorKind::Internal => Err(anyhow!("This is an example of an internal error")
.context("This is an example of extra context")),
ErrorKind::Panic => panic!("This is an example of a panic"),
}
}