feat: Proper error handling
- Bump version to 0.8.0 - Added discord error struct - All errors now implement std::error::Error - Implemented error handler instead of relying on default - Fixed bug where you could send answer on a completed quest
This commit is contained in:
parent
38e3f149b1
commit
99812c5d7c
14 changed files with 163 additions and 138 deletions
|
|
@ -5,18 +5,19 @@ use dotenvy::dotenv;
|
|||
use poise::serenity_prelude as serenity;
|
||||
use squad_quest::config::Config;
|
||||
|
||||
use crate::config::{ConfigImpl, DiscordConfig};
|
||||
use crate::{commands::error_handler, config::{ConfigImpl, DiscordConfig}, error::Error};
|
||||
|
||||
mod commands;
|
||||
mod cli;
|
||||
mod config;
|
||||
mod account;
|
||||
mod error;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Data {
|
||||
pub config: Config,
|
||||
pub discord: Arc<Mutex<DiscordConfig>>,
|
||||
}
|
||||
type Error = Box<dyn std::error::Error + Send + Sync>;
|
||||
type Context<'a> = poise::Context<'a, Data, Error>;
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -35,6 +36,7 @@ async fn main() {
|
|||
|
||||
let framework = poise::Framework::builder()
|
||||
.options(poise::FrameworkOptions {
|
||||
on_error: |err| Box::pin(error_handler(err)),
|
||||
commands: vec![
|
||||
commands::quest::quest(),
|
||||
commands::register(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue