refactor(proto): replace anyhow with thiserror in handshake

This commit is contained in:
Jindřich Moravec 2023-12-15 16:31:10 +01:00
parent da6410ce05
commit 165f871324
3 changed files with 25 additions and 2 deletions

View file

@ -0,0 +1,21 @@
use thiserror::Error;
use tokio::io;
use crate::message::errors::ProtoDeserializeError;
use crate::reader::errors::{ProtoConsumeError, ProtoPeekError};
use crate::writer::errors::ProtoWriteError;
#[derive(Debug, Error)]
pub enum ServerHandshakeError {
#[error("startup message not found")]
MissingStartupMessage,
#[error("reading from socket failed")]
Io(#[from] io::Error),
#[error("deserialization of inner data failed")]
Deserialize(#[from] ProtoDeserializeError),
#[error("peeking special message failed")]
Peek(#[from] ProtoPeekError),
#[error("consuming special message failed")]
Consume(#[from] ProtoConsumeError),
#[error("writing message to socket failed")]
Write(#[from] ProtoWriteError),
}