Skip to main content

brokapi_tbank_protocol/
error.rs

1//! Protocol-level errors.
2
3use thiserror::Error;
4
5/// Error raised while building the configuration or the channel. No request was sent yet.
6///
7/// The connectors turn it into `brokapi_core::Error::Config` at start. It never describes a failed
8/// call: calls fail with a `tonic::Status`.
9#[derive(Error, Debug)]
10pub enum ProtocolError {
11    /// The configuration cannot be used: the token or the app name has characters a header cannot
12    /// carry, or the endpoint is not a valid URL. Fix the value, retrying changes nothing.
13    #[error("invalid configuration: {0}")]
14    Config(String),
15    /// The transport could not be set up (for example the TLS configuration was refused). The
16    /// channel connects lazily, so an unreachable server is not reported here but on the first call.
17    #[error("transport error: {0}")]
18    Transport(#[from] tonic::transport::Error),
19}