1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

use serde_json;
use snafu::Snafu;

use eth_state_server_common::conversions::{MessageConversionError, StateConversionError};

#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
pub enum StateServerError {
    #[snafu(display("Tonic error in {}: {}", context, source))]
    TonicError {
        context: String,
        source: tonic::Status,
    },

    #[snafu(display("Transport error: {}", source))]
    TransportError { source: tonic::transport::Error },

    #[snafu(display("Serialize error: {}", source))]
    SerializeError { source: serde_json::Error },

    #[snafu(display("Message conversion error in {}: {}", context, source))]
    MessageConversion {
        context: String,
        source: MessageConversionError,
    },

    #[snafu(display("State conversion error in {}: {}", context, source))]
    StateConversion {
        context: String,
        source: StateConversionError,
    },
}

pub type Result<T> = std::result::Result<T, StateServerError>;