Skip to main content

openauth_core/
error.rs

1//! Error types for OpenAuth core.
2
3/// Core library error.
4#[derive(Debug, thiserror::Error, PartialEq, Eq)]
5pub enum OpenAuthError {
6    #[error("invalid configuration: {0}")]
7    InvalidConfig(String),
8    #[error("crypto error: {0}")]
9    Crypto(String),
10    #[error("invalid secret configuration: {0}")]
11    InvalidSecretConfig(String),
12    #[error("password hash error: {0}")]
13    PasswordHash(String),
14    #[error("cookie error: {0}")]
15    Cookie(String),
16    #[error("api error: {0}")]
17    Api(String),
18    #[error("oauth error: {0}")]
19    OAuth(String),
20    #[error("no request state found in the current async scope")]
21    RequestStateMissing,
22    #[error("request state value had an unexpected type")]
23    RequestStateTypeMismatch,
24    #[error("schema table `{table}` was not found")]
25    TableNotFound { table: String },
26    #[error("schema field `{field}` was not found in table `{table}`")]
27    FieldNotFound { table: String, field: String },
28    #[error(
29        "no foreign key found between base model `{base_model}` and join model `{join_model}`"
30    )]
31    JoinForeignKeyNotFound {
32        base_model: String,
33        join_model: String,
34    },
35    #[error(
36        "multiple foreign keys found between base model `{base_model}` and join model `{join_model}`"
37    )]
38    JoinForeignKeyAmbiguous {
39        base_model: String,
40        join_model: String,
41    },
42    #[error("adapter error: {0}")]
43    Adapter(String),
44}
45
46impl From<openauth_oauth::oauth2::OAuthError> for OpenAuthError {
47    fn from(error: openauth_oauth::oauth2::OAuthError) -> Self {
48        Self::OAuth(error.to_string())
49    }
50}