Skip to main content

opentalk_client_data_persistence/
data_error.rs

1// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5use snafu::Snafu;
6
7/// The error returned from functions in this crate.
8#[derive(Debug, Snafu)]
9#[snafu(visibility(pub(crate)))]
10pub struct DataError {
11    source: Box<dyn std::error::Error + Send + Sync>,
12}
13
14impl DataError {
15    /// Create a [DataError] from a boxed error.
16    pub fn new_from_boxed(source: Box<dyn std::error::Error + Send + Sync>) -> Self {
17        Self { source }
18    }
19
20    /// Create a [DataError] from another error.
21    pub fn new<E: std::error::Error + Send + Sync + 'static>(source: E) -> Self {
22        Self::new_from_boxed(Box::new(source))
23    }
24}