verse_session_id/
errors.rs

1use ed25519_dalek::SignatureError;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum SessionIdError {
6    #[error("signature error: {0:?} {1}:{2}")]
7    Signature(SignatureError, String, u32),
8    #[error("convert error: {0}:{1}")]
9    Convert(String, u32),
10    #[error("required error: {0}:{1}")]
11    Required(String, u32),
12}
13
14#[macro_export]
15macro_rules! signature {
16    () => {
17        |v| errors::SessionIdError::Signature(v, file!().to_string(), line!())
18    };
19}
20
21#[macro_export]
22macro_rules! required {
23    () => {
24        || errors::SessionIdError::Required(file!().to_string(), line!())
25    };
26}
27
28#[macro_export]
29macro_rules! convert {
30    () => {
31        anyhow::Error::from(errors::SessionIdError::Convert(
32            file!().to_string(),
33            line!(),
34        ))
35    };
36    ( $v:expr ) => {
37        anyhow::anyhow!(errors::SessionIdError::Convert(
38            format!("{},   {}", $v, file!().to_string()),
39            line!()
40        ))
41    };
42}
43pub(crate) use convert;
44pub(crate) use required;
45pub(crate) use signature;