openstack_keystone_core/application_credential/error.rs
1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5// http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14//! # Application credential provider error.
15use thiserror::Error;
16
17use crate::common::password_hashing::PasswordHashError;
18use crate::error::BuilderError;
19
20/// Application credential provider error.
21#[derive(Error, Debug)]
22pub enum ApplicationCredentialProviderError {
23 /// AccessRule with matching ID and another one matching rest of parameters
24 /// is found.
25 #[error("more than one access rule matching the ID and parameters found")]
26 AccessRuleConflict,
27
28 /// Conflict.
29 #[error("conflict: {0}")]
30 Conflict(String),
31
32 /// Driver error.
33 #[error("backend driver error: {0}")]
34 Driver(String),
35
36 /// DateTime parsing error.
37 #[error("error parsing int column as datetime: {expires_at}")]
38 ExpirationDateTimeParse { id: String, expires_at: i64 },
39
40 /// Password hashing error.
41 #[error(transparent)]
42 PasswordHash {
43 /// The source of the error.
44 #[from]
45 source: PasswordHashError,
46 },
47
48 /// Role Database error.
49 #[error(transparent)]
50 Role {
51 /// The source of the error.
52 #[from]
53 source: crate::role::RoleProviderError,
54 },
55
56 /// Secret is missing.
57 #[error("secret missing")]
58 SecretMissing,
59
60 /// (de)serialization error.
61 #[error(transparent)]
62 Serde {
63 #[from]
64 source: serde_json::Error,
65 },
66
67 /// Structures builder error.
68 #[error(transparent)]
69 StructBuilder {
70 /// The source of the error.
71 #[from]
72 source: BuilderError,
73 },
74 /// Unsupported driver.
75 #[error("unsupported driver `{0}` for the application credential provider")]
76 UnsupportedDriver(String),
77
78 /// Request validation error.
79 #[error("request validation error: {}", source)]
80 Validation {
81 /// The source of the error.
82 #[from]
83 source: validator::ValidationErrors,
84 },
85}