krossbar_rpc/
error.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4#[derive(Debug, Serialize, Deserialize, Clone, Error)]
5pub enum Error {
6    /// User is not allowed to register with a provided service name, or
7    /// not allowed to connect to a requested client
8    #[error("Connection or service name is not allowed")]
9    NotAllowed,
10    /// Not such endpoint to call or subscribe to
11    #[error("Requested endpoint is not registered")]
12    NoEndpoint,
13    /// Service or endpoind had been registered already
14    #[error("Service or endpoint is already registered")]
15    AlreadyRegistered,
16    /// Not found a requested service
17    #[error("Requested service is not found")]
18    ServiceNotFound,
19    /// Peer disconnected
20    #[error("Peer disconencted")]
21    PeerDisconnected,
22    /// Invalid params to a call. Contains deserialization error
23    #[error("Invalid call params: {0}")]
24    ParamsTypeError(String),
25    /// Invalid result type of an enpoint requested. Either call result type, or
26    /// subscription result type. COntains deserialization error
27    #[error("Invalid result type: {0}")]
28    ResultTypeError(String),
29    /// Internal library error. Should never happen
30    #[error("Internal Krossbar error: {0}. Please report the issue")]
31    InternalError(String),
32    /// Client error
33    #[error("Client returned an error: {0}")]
34    ClientError(String),
35}
36
37pub type Result<T> = std::result::Result<T, Error>;