fire_stream/
error.rs

1use crate::packet::PacketError;
2
3use std::{io, fmt};
4use std::error::Error;
5
6
7#[derive(Debug)]
8#[non_exhaustive]
9pub enum TaskError {
10	#[cfg(feature = "connection")]
11	Join(tokio::task::JoinError),
12	Io(io::Error),
13	/// Reading a packet failed
14	Packet(PacketError),
15	/// gets returned if a packet with an id was received which is unknown
16	/// This means a hard error and the connection should be closed
17	UnknownId(u32),
18	ExistingId(u32),
19	WrongPacketKind(&'static str),
20	/// Incorrect signature
21	#[cfg(feature = "encrypted")]
22	#[cfg_attr(docsrs, doc(cfg(feature = "encrypted")))]
23	IncorrectSignature
24}
25
26impl fmt::Display for TaskError {
27	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
28		fmt::Debug::fmt(self, f)
29	}
30}
31
32impl Error for TaskError {}
33
34
35#[derive(Debug)]
36#[non_exhaustive]
37pub enum RequestError {
38	/// If the connection was already closed when you called request
39	/// 
40	/// Depending on ReconnectStrat you might wan't to call request again
41	ConnectionAlreadyClosed,
42	/// Only get's returned if something wen't wrong and we won't be able
43	/// to get an better error, probably means the connection closed
44	TaskFailed,
45	/// The other side responded with no response. This means the other side
46	/// didn't bother to send a response.
47	NoResponse,
48	/// If the request you sent could not be parsed successfully by the server
49	MalformedRequest,
50	/// The error that originated while parsing the response
51	ResponsePacket(PacketError)
52}
53
54impl fmt::Display for RequestError {
55	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56		fmt::Debug::fmt(self, f)
57	}
58}
59
60impl Error for RequestError {}
61
62
63#[derive(Debug)]
64#[non_exhaustive]
65pub enum ResponseError {
66	ConnectionClosed
67}
68
69impl fmt::Display for ResponseError {
70	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71		fmt::Debug::fmt(self, f)
72	}
73}
74
75impl Error for ResponseError {}
76
77
78/// Returned from a StreamSender or StreamReceiver
79#[derive(Debug)]
80#[non_exhaustive]
81pub enum StreamError {
82	StreamAlreadyClosed
83}
84
85impl fmt::Display for StreamError {
86	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87		fmt::Debug::fmt(self, f)
88	}
89}
90
91impl Error for StreamError {}