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}
22
23impl fmt::Display for Error {
24    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25        write!(f, "Data-Driver Error: {:?}", &self)
26    }
27}
28
29impl From<serde_json::Error> for Error {
30    fn from(value: serde_json::Error) -> Self {
31        Self::Json(value.to_string())
32    }
33}