Updated derive more to v1. Removed thiserror

This commit is contained in:
2024-08-11 12:19:33 +03:00
parent 5c789533e3
commit 14b858808d
4 changed files with 101 additions and 66 deletions

View File

@ -15,16 +15,14 @@ pub fn validate_field(field: &str) -> bool {
.all(|char| !['`', '\\', '\n', '\t'].contains(&char))
}
#[derive(thiserror::Error, Debug)]
#[derive(derive_more::Error, derive_more::Display, derive_more::From, Debug)]
pub enum Error {
#[error("Invalid input length")]
#[display("Invalid input length")]
InvalidInputLength,
#[error(transparent)]
ChaCha(#[from] chacha20poly1305::Error),
ChaCha(chacha20poly1305::Error),
#[error(transparent)]
InvalidUTF8(#[from] std::string::FromUtf8Error),
InvalidUTF8(std::string::FromUtf8Error),
}
type Result<T> = std::result::Result<T, Error>;

View File

@ -1,23 +1,23 @@
use std::fmt::{Debug, Display};
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
#[derive(thiserror::Error, Debug)]
#[error("No user info found")]
#[derive(derive_more::Error, derive_more::Display, Debug)]
#[display("No user info found")]
pub struct NoUserInfo;
#[derive(thiserror::Error, Debug)]
#[error("Handler was already used")]
#[derive(derive_more::Error, derive_more::Display, Debug)]
#[display("Handler was already used")]
pub struct HandlerUsed;
#[derive(thiserror::Error, Debug)]
#[derive(derive_more::Error, derive_more::Display, derive_more::From, Debug)]
pub enum InvalidCommand {
#[error("Invalid params")]
#[display("Invalid params")]
InvalidParams,
#[error("Not enough bytes in the name's hash")]
#[display("Not enough bytes in the name's hash")]
InvalidOutputLength,
#[error("Error decoding the values: {0}")]
NameDecodingError(#[from] base64::DecodeError),
#[error("Unknown locale passed into callback")]
#[display("Error decoding the values: {}", 0)]
NameDecodingError(base64::DecodeError),
#[display("Unknown locale passed into callback")]
UnknownLocale,
}