Skip to content

Commit

Permalink
Move InvalidUrl error into Command
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNorom committed Sep 17, 2023
1 parent 6616a2d commit f91c3f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/commands/banner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub async fn start(
}

// album url
let album_url = album.parse::<Url>()?;
let album_url = album.parse::<Url>().map_err(CommandErr::InvalidUrl)?;
let album = Album::try_from(&album_url)?;

let user_data = ctx.data();
Expand Down Expand Up @@ -147,7 +147,7 @@ pub async fn start_for_guild(
}

// album url
let album_url = album.parse::<Url>()?;
let album_url = album.parse::<Url>().map_err(CommandErr::InvalidUrl)?;
let album = Album::try_from(&album_url)?;

let user_data = ctx.data();
Expand Down
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fmt::{Debug, Display};

use poise::serenity_prelude::User;
use thiserror::Error;
use url::ParseError;

use crate::{
album_provider::ProviderError,
Expand All @@ -20,9 +21,6 @@ pub enum Error {
#[error(transparent)]
Redis(#[from] fred::error::RedisError),

#[error(transparent)]
InvalidUrl(#[from] url::ParseError),

#[error(transparent)]
Command(#[from] Command),

Expand Down Expand Up @@ -57,6 +55,8 @@ pub enum Command {
GuildHasNoBannerSet,
#[error("Server doesn't have the required boost level")]
GuildHasNoBannerFeature,
#[error("Album is not a valid URL")]
InvalidUrl(ParseError),
}

#[derive(Debug, thiserror::Error)]
Expand Down

0 comments on commit f91c3f6

Please sign in to comment.