Skip to main content

openstack_keystone_core/identity_mapping/
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
15use thiserror::Error;
16
17//use crate::api::error::KeystoneApiError;
18use crate::error::BuilderError;
19
20/// Identity mapping provider error.
21#[derive(Error, Debug)]
22pub enum IdentityMappingProviderError {
23    /// Conflict.
24    #[error("conflict: {0}")]
25    Conflict(String),
26
27    /// Driver error.
28    #[error("backend driver error: {0}")]
29    Driver(String),
30
31    /// (de)serialization error.
32    #[error("data serialization error")]
33    Serde {
34        #[from]
35        source: serde_json::Error,
36    },
37
38    /// Structures builder error.
39    #[error(transparent)]
40    StructBuilder {
41        /// The source of the error.
42        #[from]
43        source: BuilderError,
44    },
45
46    /// Unsupported driver.
47    #[error("unsupported driver `{0}` for the identity mapping provider")]
48    UnsupportedDriver(String),
49
50    /// Request validation error.
51    #[error("request validation error: {}", source)]
52    Validation {
53        /// The source of the error.
54        #[from]
55        source: validator::ValidationErrors,
56    },
57}
58
59//impl From<IdentityMappingProviderError> for KeystoneApiError {
60//    fn from(source: IdentityMappingProviderError) -> Self {
61//        match source {
62//            IdentityMappingProviderError::Conflict(x) => Self::Conflict(x),
63//            other => Self::InternalError(other.to_string()),
64//        }
65//    }
66//}