Skip to main content

scrybe_core/
error.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Shawn Hartsock and contributors
3
4//! Error types for scrybe-core.
5
6/// Top-level error type for scrybe-core operations.
7#[derive(Debug, thiserror::Error)]
8pub enum ScrybeError {
9    #[error("I/O error: {0}")]
10    Io(#[from] std::io::Error),
11    #[error("serialization error: {0}")]
12    Serde(#[from] serde_json::Error),
13    #[error("CBOR encoding error: {0}")]
14    Cbor(String),
15    #[error("{0}")]
16    Other(String),
17}
18
19impl ScrybeError {
20    /// Creates an error from any display-able value.
21    pub fn msg(msg: impl std::fmt::Display) -> Self {
22        Self::Other(msg.to_string())
23    }
24}
25
26pub type Result<T> = std::result::Result<T, ScrybeError>;