2021-11-21 22:58:16 -05:00
|
|
|
//! Error handling.
|
|
|
|
|
|
|
|
use std::result;
|
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
pub type Result<T, E = Error> = result::Result<T, E>;
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
2021-11-23 11:29:53 -05:00
|
|
|
pub enum Error {
|
|
|
|
#[error("command from client not recognized")]
|
|
|
|
CommandNotFound,
|
2021-11-23 11:46:47 -05:00
|
|
|
#[error("parsing JSON->Event failed")]
|
|
|
|
EventParseFailed,
|
|
|
|
#[error("parsing JSON->Req failed")]
|
|
|
|
ReqParseFailed,
|
|
|
|
#[error("parsing JSON->Close failed")]
|
|
|
|
CloseParseFailed,
|
2021-11-23 12:32:19 -05:00
|
|
|
#[error("JSON parsing failed")]
|
|
|
|
JsonParseFailed(serde_json::Error),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<serde_json::Error> for Error {
|
|
|
|
fn from(r: serde_json::Error) -> Self {
|
|
|
|
Error::JsonParseFailed(r)
|
|
|
|
}
|
2021-11-23 11:29:53 -05:00
|
|
|
}
|