openstack_keystone_core/resource/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#[derive(Error, Debug)]
18pub enum ResourceProviderError {
19 /// Conflict.
20 #[error("conflict: {0}")]
21 Conflict(String),
22
23 /// Domain not found.
24 #[error("domain {0} not found")]
25 DomainNotFound(String),
26
27 /// Driver error.
28 #[error("backend driver error: {0}")]
29 Driver(String),
30
31 /// (De)Ser error.
32 #[error(transparent)]
33 Serde {
34 /// The source of the error.
35 #[from]
36 source: serde_json::Error,
37 },
38
39 /// Structures builder error.
40 #[error(transparent)]
41 StructBuilder {
42 /// The source of the error.
43 #[from]
44 source: crate::error::BuilderError,
45 },
46
47 /// Project not found.
48 #[error("project {0} not found")]
49 ProjectNotFound(String),
50
51 /// Unsupported driver.
52 #[error("unsupported driver `{0}` for the resource provider")]
53 UnsupportedDriver(String),
54
55 /// Request validation error.
56 #[error("request validation error: {}", source)]
57 Validation {
58 /// The source of the error.
59 #[from]
60 source: validator::ValidationErrors,
61 },
62}