/
Kuj1
/
ds_point
Обзор
Документация
Войти
/
Kuj1
/
ds_point
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/errors.rs
54 строки
1 KB
kuj1
refactored code
17 июл 2024, 00:12
17 июл 2024, 00:12
6b22bd9
Код
Авторство
О чём код?
use std::{io, num::ParseIntError}; use thiserror::Error; use tokio::sync::broadcast::error::RecvError; use crate::bot::{MsgForSend, TextMsg}; pub type SendDataResult = Result<(), SendDataError>; pub type ReceiveMessageResult = Result<MsgForSend, ReceiveMsgError>; pub type TextMsgResult = Result<TextMsg, serenity::Error>; pub type ReceiveDataResult = Result<String, ReceiveDataError>; #[derive(Debug, Error)] pub enum SendDataError { #[error("IO error: {0}")] Io(#[from] io::Error), } #[derive(Debug, Error)] pub enum ReceiveDataError { #[error("TCP error: {0}")] Io(#[from] io::Error), #[error("Bad encoding")] BadEncoding, } #[derive(Debug, Error)] pub enum ReceiveMsgError { #[error("Receiver error: {0}")] ReceiveMsg(#[from] RecvError), } #[derive(Debug, Error)] pub enum ConnectionError { #[error("Bad connection")] BadConnection, #[error(transparent)] SocketInfoError(#[from] io::Error), } #[derive(Debug, Error)] pub enum BotError { #[error(transparent)] SendError(#[from] SendDataError), #[error(transparent)] ReceiveError(#[from] ReceiveDataError), #[error(transparent)] ConnectionError(#[from] ConnectionError), #[error(transparent)] SocketInfoError(#[from] io::Error), #[error(transparent)] ClientBulderError(#[from] serenity::Error), #[error(transparent)] ParsingCommandError(#[from] ParseIntError), }