dusk_data_driver/
error.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4//
5// Copyright (c) DUSK NETWORK. All rights reserved.
6
7//! Error-type for dusk-core.
8
9use alloc::string::{String, ToString};
10use core::fmt;
11
12/// The dusk-core error type.
13#[derive(Debug, Clone, PartialEq)]
14pub enum Error {
15    /// Rkyv serialization.
16    Rkyv(String),
17    /// Json serialization
18    Json(String),
19    /// Unsupported
20    Unsupported(String),
21    /// Other
22    Other(String),
23}
24
25impl fmt::Display for Error {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        write!(f, "Data-Driver Error: {:?}", &self)
28    }
29}
30
31impl From<serde_json::Error> for Error {
32    fn from(value: serde_json::Error) -> Self {
33        Self::Json(value.to_string())
34    }
35}