mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 04:35:03 +01:00
error handling
This commit is contained in:
parent
fc131327b2
commit
232c1d2830
4 changed files with 99 additions and 14 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use crate::methods::{ReplyCode, ReplyText};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ProtocolError {
|
||||
#[error("fatal error")]
|
||||
|
|
@ -9,7 +11,7 @@ pub enum ProtocolError {
|
|||
#[error("Connection must be closed")]
|
||||
CloseNow,
|
||||
#[error("Graceful connection closing requested")]
|
||||
GracefulClose,
|
||||
GracefullyClosed,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
|
@ -31,5 +33,31 @@ pub enum ConException {
|
|||
Todo,
|
||||
}
|
||||
|
||||
impl ConException {
|
||||
pub fn reply_code(&self) -> ReplyCode {
|
||||
match self {
|
||||
ConException::FrameError => 501,
|
||||
ConException::CommandInvalid => 503,
|
||||
ConException::SyntaxError(_) => 503,
|
||||
ConException::ChannelError => 504,
|
||||
ConException::UnexpectedFrame => 505,
|
||||
ConException::NotImplemented(_) => 540,
|
||||
ConException::Todo => 0,
|
||||
}
|
||||
}
|
||||
pub fn reply_text(&self) -> ReplyText {
|
||||
"cant be bothered yet".to_string() // todo
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum ChannelException {}
|
||||
|
||||
impl ChannelException {
|
||||
pub fn reply_code(&self) -> ReplyCode {
|
||||
todo!()
|
||||
}
|
||||
pub fn reply_text(&self) -> ReplyText {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue