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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Custom errors that are used in radius-rust crate to notify users of RADIUS specific error
//! states


use thiserror::Error;

// TODO - https://rust-lang.github.io/api-guidelines/naming.html#c-word-order
#[derive(Debug, Error)]
/// Represents all errors generated by this library
pub enum RadiusError {
    /// Error happens, when Radius Packet fails validation
    #[error("Verification failed for incoming Radius packet")]
    ValidationError         {
        /// Error definition received from crate
        error: String
    },
    /// Error happens, when packet has been badly constructed or got corrupted
    #[error("Radius packet is malformed")]
    MalformedPacketError    {
        /// Error definition received from crate
        error: String
    },
    /// Error happens, when attribute has been badly constructed or got corrupted
    #[error("Radius packet attribute is malformed")]
    MalformedAttributeError {
        /// Error definition received from crate
        error: String
    },
    /// Error happens, when IPv6 Address was badly added to Radius Packet or got corrupted
    #[error("Provided IPv6 address is malformed")]
    MalformedIpAddrError    {
        /// Error definition received from crate
        error: String
    },
    /// Error happens, when there is some sort of connection error between sockets, or socket
    /// cannot bind to the given hostname/port
    #[error(transparent)]
    SocketConnectionError(#[from] std::io::Error),
    /// Error won't happen, but represents the case when socket gets message from unknwon source
    #[error("Invalid socket connection")]
    SocketInvalidConnectionError {
        /// Error definition received from crate
        error: String
    },
    /// Error happens, when socket cannot parse given hostname/port
    #[error(transparent)]
    SocketAddrParseError(#[from] std::net::AddrParseError),
    /// Error happens, when dictionary file cannot be parsed
    #[error("Dictionary is malformed or inaccessible")]
    MalformedDictionaryError     {
        /// Error definition received from crate
        error: std::io::Error
    },
    /// Error happens, when wrong RADIUS Code is supplied
    #[error("Supplied RADIUS Code is not supported by this library")]
    UnsupportedTypeCodeError     {
        /// Error definition received from crate
        error: String
    },
}