Skip to main content

opentalk_client_data_persistence/
config_error.rs

1// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5use std::path::PathBuf;
6
7use snafu::Snafu;
8
9/// The error returned from config functions in this crate.
10#[derive(Debug, Snafu)]
11#[snafu(visibility(pub(crate)))]
12pub enum ConfigError {
13    /// Config can't be loaded from a path.
14    #[snafu(display("Config can't be loaded from {path:?}"))]
15    NotLoadable {
16        /// The path from which the loading was attempted.
17        path: PathBuf,
18
19        /// The source error causing the failure.
20        source: std::io::Error,
21    },
22
23    /// Config can't be stored to a path.
24    #[snafu(display("Config can't be stored to {path:?}"))]
25    NotStorable {
26        /// The path to which the storing was attempted.
27        path: PathBuf,
28
29        /// The source error causing the failure.
30        source: std::io::Error,
31    },
32
33    /// The config folder can't be created under a path.
34    #[snafu(display("Config folder can't be created under {path:?}"))]
35    FolderNotCreatable {
36        /// The path that was attempted to be created.
37        path: PathBuf,
38
39        /// The source error causing the failure.
40        source: std::io::Error,
41    },
42
43    /// The system data home is not set.
44    #[snafu(display("System config home not set"))]
45    SystemConfigHomeNotSet,
46
47    /// Config can't be read from a path.
48    #[snafu(display("Config not readable from {path:?}"))]
49    NotReadable {
50        /// The path from which the reading was attempted.
51        path: PathBuf,
52
53        /// The toml deserialization error causing the failure.
54        source: toml::de::Error,
55    },
56
57    /// Config can't be written to a path.
58    #[snafu(display("Config not writeable to {path:?}"))]
59    NotWriteable {
60        /// The path to which the writing was attempted.
61        path: PathBuf,
62
63        /// The toml serialization error causing the failure.
64        source: toml::ser::Error,
65    },
66}