#discord-bot #slash-command #poise-error #intentionally #on-error

poise_error

An opinionated plug-and-play library for error handling in Discord bots made with poise

5 stable releases

Uses new Rust 2024

new 1.4.0 Apr 12, 2025
1.3.0 Apr 6, 2025
1.2.0 Jan 24, 2025
1.1.0 Jan 23, 2025
1.0.0 Jan 21, 2025

#591 in Debugging

Download history 247/week @ 2025-01-18 79/week @ 2025-01-25 22/week @ 2025-02-01 4/week @ 2025-02-08 16/week @ 2025-02-15 6/week @ 2025-02-22 3/week @ 2025-03-01 1/week @ 2025-03-08 1/week @ 2025-03-15 122/week @ 2025-04-05

123 downloads per month

MIT license

22KB
397 lines

poise_error

An 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.

Examples

Goober Bot is a Discord bot which uses poise_error, here's how it looks:

Screenshot 2025-01-22 at 6 23 00 PM

Screenshot 2025-01-22 at 6 24 01 PM

/// Fails intentionally
#[command(slash_command)]
async fn error(
    _ctx: Context<'_>,
    #[description = "Kind of error to return"] kind: ErrorKind,
) -> Result<(), poise_error::anyhow::Error> {
    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"),
    }
}

Dependencies

~15–29MB
~424K SLoC