Skip to main content

cnf_lib/
error.rs

1// SPDX-License-Identifier: GPL-3.0-or-later
2// SPDX-FileCopyrightText: (C) 2023 Andreas Hartmann <hartan@7x.de>
3// This file is part of cnf-lib, available at <https://gitlab.com/hartang/rust/cnf>
4
5//! # CNF Error Types
6use thiserror::Error;
7
8/// Useful functions and bits for error handling.
9pub mod prelude {
10    pub use super::CnfError;
11    pub use anyhow::{Context, anyhow};
12
13    /// Type alias for errors in this crate
14    pub type Result<T> = std::result::Result<T, CnfError>;
15}
16
17/// Public error type for `cnf`.
18#[derive(Error, Debug)]
19pub enum CnfError {
20    /// Transparent error from any source
21    #[error(transparent)]
22    ApplicationError(#[from] anyhow::Error),
23
24    /// Required feature not implemented yet
25    #[error("please implement '{0}' first!")]
26    NotImplemented(String),
27}