From b7526950572db58ebc4f31266256631df31980e3 Mon Sep 17 00:00:00 2001 From: naskya Date: Mon, 10 Jun 2024 18:09:08 +0900 Subject: [PATCH] chore (backend-rs): use proper error type --- packages/backend-rs/src/federation/acct.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/backend-rs/src/federation/acct.rs b/packages/backend-rs/src/federation/acct.rs index e332c31e32..ffc972ba84 100644 --- a/packages/backend-rs/src/federation/acct.rs +++ b/packages/backend-rs/src/federation/acct.rs @@ -7,10 +7,13 @@ pub struct Acct { pub host: Option, } -impl FromStr for Acct { - type Err = (); +#[derive(thiserror::Error, Debug)] +#[error("failed to convert string '{0}' into acct")] +pub struct InvalidAcctString(String); + +impl FromStr for Acct { + type Err = InvalidAcctString; - /// This never throw errors. Feel free to `.unwrap()` the result. fn from_str(value: &str) -> Result { let split: Vec<&str> = if let Some(stripped) = value.strip_prefix('@') { stripped