steamkit/steam/authentication/
authentication_exception.rs1use crate::base::generated::steam_language::EResult;
4use crate::error::SteamError;
5
6#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
8pub enum AuthenticationException {
9 #[error("{message} with result {result:?}.")]
11 Failed {
12 message: String,
14 result: EResult,
16 },
17
18 #[error("{message}")]
20 Other {
21 message: String,
23 },
24}
25
26impl AuthenticationException {
27 pub fn failed(message: impl Into<String>, result: EResult) -> Self {
29 AuthenticationException::Failed {
30 message: message.into(),
31 result,
32 }
33 }
34
35 pub fn other(message: impl Into<String>) -> Self {
37 AuthenticationException::Other {
38 message: message.into(),
39 }
40 }
41
42 pub fn result(&self) -> Option<EResult> {
44 match self {
45 AuthenticationException::Failed { result, .. } => Some(*result),
46 AuthenticationException::Other { .. } => None,
47 }
48 }
49}
50
51impl From<AuthenticationException> for SteamError {
52 fn from(value: AuthenticationException) -> Self {
54 SteamError::Authentication(value.to_string())
55 }
56}