init_data_rust/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::time::SystemTimeError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum ParseDataError {
    #[error("Invalid signature: {0}")]
    InvalidSignature(#[from] serde_json::Error),

    #[error("Invalid query string: {0}")]
    InvalidQueryString(#[from] url::ParseError),
}

#[derive(Debug, Error)]
pub enum SignError {
    #[error("Could not process signature")]
    CouldNotProcessSignature,

    #[error("Could not process auth time: {0}")]
    CouldNotProcessAuthTime(#[from] SystemTimeError),
}

#[derive(Debug, Error)]
pub enum ValidationError {
    #[error("Invalid query string: {0}")]
    InvalidQueryString(#[from] url::ParseError),

    #[error("Unexpected format")]
    UnexpectedFormat,

    #[error("Signature is missing")]
    SignMissing,

    #[error("Auth date is missing")]
    AuthDateMissing,

    #[error("Data has expired")]
    Expired,

    #[error("Signature is invalid")]
    SignInvalid,
}