mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-25 12:57:07 +00:00
Switch from err-derive to thiserror
thiserror is easier to use, has fewer dependencies and is more popular.
This commit is contained in:
committed by
Benjamin Saunders
parent
766d20a592
commit
1bca0f7c2a
+1
-1
@@ -26,7 +26,6 @@ maintenance = { status = "experimental" }
|
||||
|
||||
[dependencies]
|
||||
bytes = "0.5.2"
|
||||
err-derive = "0.2.3"
|
||||
futures = "0.3.1"
|
||||
futures-util = { version = "0.3", default-features = false }
|
||||
http = "0.2"
|
||||
@@ -36,6 +35,7 @@ pin-project = "^0.4.21"
|
||||
quinn-proto = { path = "../quinn-proto", version = "0.6.0" }
|
||||
quinn = { path = "../quinn", version = "0.6.0", features = ["tls-rustls"] }
|
||||
rustls = { git = "https://github.com/ctz/rustls", rev = "fee894f7e030", features = ["quic"] }
|
||||
thiserror = "1.0.21"
|
||||
tokio = "0.2.6"
|
||||
tokio-util = { version = "0.3.0", features = ["codec"] }
|
||||
tracing = "0.1.10"
|
||||
|
||||
+16
-16
@@ -108,9 +108,9 @@ mod qpack;
|
||||
#[doc(hidden)]
|
||||
pub mod qpack;
|
||||
|
||||
use err_derive::Error;
|
||||
use quinn::{ApplicationClose, ConnectionError, ReadError, StoppedError, VarInt, WriteError};
|
||||
use std::{error::Error as StdError, io::ErrorKind};
|
||||
use thiserror::Error;
|
||||
|
||||
use proto::ErrorCode;
|
||||
|
||||
@@ -121,49 +121,49 @@ pub type ZeroRttAccepted = quinn::ZeroRttAccepted;
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
/// Cannot make a new request, bescause the connection is closing
|
||||
#[error(display = "Connection is closing, resquest aborted")]
|
||||
#[error("Connection is closing, resquest aborted")]
|
||||
Aborted,
|
||||
/// Protocol violation detected by the internal HTTP/3 protocol state machine
|
||||
#[error(display = "H3 protocol error: {:?}", _0)]
|
||||
#[error("H3 protocol error: {0:?}")]
|
||||
Proto(proto::connection::Error),
|
||||
/// Error occurred at the `QUIC` level
|
||||
#[error(display = "QUIC protocol error: {}", _0)]
|
||||
#[error("QUIC protocol error: {0}")]
|
||||
Quic(quinn::ConnectionError),
|
||||
/// A `QUIC`-specific read error occurred
|
||||
#[error(display = "QUIC read error: {}", _0)]
|
||||
#[error("QUIC read error: {0}")]
|
||||
Read(ReadError),
|
||||
/// A `QUIC`-specific write error occurred
|
||||
#[error(display = "QUIC write error: {}", _0)]
|
||||
#[error("QUIC write error: {0}")]
|
||||
Write(WriteError),
|
||||
/// A `QUIC`-specific error occurred while polling for STOP_SENDING
|
||||
#[error(display = "QUIC error while polling for STOP_SENDING: {}", _0)]
|
||||
#[error("QUIC error while polling for STOP_SENDING: {0}")]
|
||||
Stopped(StoppedError),
|
||||
/// Programming error within the crate's code
|
||||
#[error(display = "Internal error: {}", _0)]
|
||||
#[error("Internal error: {0}")]
|
||||
Internal(String),
|
||||
/// The peer's behavior was detected as incorrect or malicious
|
||||
#[error(display = "Incorrect peer behavior: {}", _0)]
|
||||
#[error("Incorrect peer behavior: {0}")]
|
||||
Peer(String),
|
||||
/// The peer tried to open an unidirectional stream with an unknown type code
|
||||
#[error(display = "unknown stream type {}", _0)]
|
||||
#[error("unknown stream type {0}")]
|
||||
UnknownStream(u64),
|
||||
/// An IO error occurred
|
||||
#[error(display = "IO error: {}", _0)]
|
||||
#[error("IO error: {0}")]
|
||||
Io(std::io::Error),
|
||||
/// An overflow occurred into the `QPACK` decoder
|
||||
#[error(display = "Overflow max data size")]
|
||||
#[error("Overflow max data size")]
|
||||
Overflow,
|
||||
/// A future has been polled after it was already finished
|
||||
#[error(display = "Polled after finished")]
|
||||
#[error("Polled after finished")]
|
||||
Poll,
|
||||
/// The peer issued an HTTP/3 error code and an optional text description
|
||||
#[error(display = "Http error: {:?}", _0)]
|
||||
#[error("Http error: {0:?}")]
|
||||
Http(HttpError, Option<String>),
|
||||
/// Header validity error from a client call
|
||||
#[error(display = "Header error: {:?}", _0)]
|
||||
#[error("Header error: {0:?}")]
|
||||
Header(&'static str),
|
||||
/// Polling the issued body data yielded an error
|
||||
#[error(display = "Polling body error: {}", _0)]
|
||||
#[error("Polling body error: {0}")]
|
||||
Body(Box<dyn StdError + Send + Sync>),
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use bytes::{Buf, BufMut};
|
||||
use std::{fmt, io::Cursor};
|
||||
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
use tracing::trace;
|
||||
|
||||
use super::{
|
||||
@@ -25,23 +25,23 @@ use super::{prefix_int, prefix_string};
|
||||
|
||||
#[derive(Debug, PartialEq, Error)]
|
||||
pub enum Error {
|
||||
#[error(display = "failed to parse integer: {:?}", _0)]
|
||||
#[error("failed to parse integer: {0:?}")]
|
||||
InvalidInteger(prefix_int::Error),
|
||||
#[error(display = "failed to parse string: {:?}", _0)]
|
||||
#[error("failed to parse string: {0:?}")]
|
||||
InvalidString(prefix_string::Error),
|
||||
#[error(display = "index is out of dynamic table bounds: {:?}", _0)]
|
||||
#[error("index is out of dynamic table bounds: {0:?}")]
|
||||
InvalidIndex(vas::Error),
|
||||
#[error(display = "dynamic table error: {}", _0)]
|
||||
#[error("dynamic table error: {0}")]
|
||||
DynamicTableError(DynamicTableError),
|
||||
#[error(display = "index '{}' is out of static table bounds", _0)]
|
||||
#[error("index '{}' is out of static table bounds", _0)]
|
||||
InvalidStaticIndex(usize),
|
||||
#[error(display = "invalid data prefix")]
|
||||
#[error("invalid data prefix")]
|
||||
UnknownPrefix,
|
||||
#[error(display = "missing references from dynamic table to decode header block")]
|
||||
#[error("missing references from dynamic table to decode header block")]
|
||||
MissingRefs(usize),
|
||||
#[error(display = "header prefix contains invalid base index: {:?}", _0)]
|
||||
#[error("header prefix contains invalid base index: {0:?}")]
|
||||
BadBaseIndex(isize),
|
||||
#[error(display = "data is unexpectedly truncated")]
|
||||
#[error("data is unexpectedly truncated")]
|
||||
UnexpectedEnd,
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{
|
||||
collections::{btree_map::Entry as BTEntry, hash_map::Entry, BTreeMap, HashMap, VecDeque},
|
||||
};
|
||||
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
|
||||
use super::{field::HeaderField, static_::StaticTable};
|
||||
use crate::qpack::vas::{self, VirtualAddressSpace};
|
||||
@@ -16,26 +16,23 @@ const SETTINGS_MAX_BLOCKED_STREAMS_MAX: usize = 65_535; // 2^16 - 1
|
||||
|
||||
#[derive(Debug, PartialEq, Error)]
|
||||
pub enum Error {
|
||||
#[error(display = "bad relative index: {}", _0)]
|
||||
#[error("bad relative index: {0}")]
|
||||
BadRelativeIndex(usize),
|
||||
#[error(display = "bad post base index: {}", _0)]
|
||||
#[error("bad post base index: {0}")]
|
||||
BadPostbaseIndex(usize),
|
||||
#[error(display = "decoded index out of bounds: {}", _0)]
|
||||
#[error("decoded index out of bounds: {0}")]
|
||||
BadIndex(usize),
|
||||
#[error(display = "tried to insert a field greater than dynamic table available size")]
|
||||
#[error("tried to insert a field greater than dynamic table available size")]
|
||||
MaxTableSizeReached,
|
||||
#[error(display = "table size setting is greater than maximum authorized")]
|
||||
#[error("table size setting is greater than maximum authorized")]
|
||||
MaximumTableSizeTooLarge,
|
||||
#[error(display = "max blocked stream setting is greater than maximum authorized")]
|
||||
#[error("max blocked stream setting is greater than maximum authorized")]
|
||||
MaxBlockedStreamsTooLarge,
|
||||
#[error(
|
||||
display = "stream id '{}' is unknown or has already been acknowledged or canceled",
|
||||
_0
|
||||
)]
|
||||
#[error("stream id '{0}' is unknown or has already been acknowledged or canceled")]
|
||||
UnknownStreamId(u64),
|
||||
#[error(display = "tried to acknowledge encoder stream but no encoder data has been sent")]
|
||||
#[error("tried to acknowledge encoder stream but no encoder data has been sent")]
|
||||
NoTrackingData,
|
||||
#[error(display = "internal reference tracking error")]
|
||||
#[error("internal reference tracking error")]
|
||||
InvalidTrackingCount,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{cmp, io::Cursor};
|
||||
|
||||
use bytes::{Buf, BufMut};
|
||||
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
|
||||
use super::{
|
||||
block::{
|
||||
@@ -26,13 +26,13 @@ use super::{
|
||||
|
||||
#[derive(Debug, PartialEq, Error)]
|
||||
pub enum Error {
|
||||
#[error(display = "failed to insert in dynamic table: {}", _0)]
|
||||
#[error("failed to insert in dynamic table: {0}")]
|
||||
Insertion(DynamicTableError),
|
||||
#[error(display = "prefixed string: {:?}", _0)]
|
||||
#[error("prefixed string: {0:?}")]
|
||||
InvalidString(StringError),
|
||||
#[error(display = "prefixed integer: {:?}", _0)]
|
||||
#[error("prefixed integer: {0:?}")]
|
||||
InvalidInteger(IntError),
|
||||
#[error(display = "invalid data prefix")]
|
||||
#[error("invalid data prefix")]
|
||||
UnknownPrefix,
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ ring = { version = "0.16.7", optional = true }
|
||||
rustls = { git = "https://github.com/ctz/rustls", rev = "fee894f7e030", features = ["quic"], optional = true }
|
||||
rustls-native-certs = { git = "https://github.com/kwantam/rustls-native-certs", rev = "52fc75ad4430", optional = true }
|
||||
slab = "0.4"
|
||||
thiserror = "1.0.21"
|
||||
tracing = "0.1.10"
|
||||
webpki = { version = "0.21", optional = true }
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
|
||||
use bytes::{Buf, BufMut};
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::VarInt;
|
||||
|
||||
#[derive(Error, Debug, Copy, Clone, Eq, PartialEq)]
|
||||
#[error(display = "unexpected end of buffer")]
|
||||
#[error("unexpected end of buffer")]
|
||||
pub struct UnexpectedEnd;
|
||||
|
||||
pub type Result<T> = ::std::result::Result<T, UnexpectedEnd>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{convert::TryInto, fmt, num::TryFromIntError, sync::Arc, time::Duration};
|
||||
|
||||
use err_derive::Error;
|
||||
use rand::RngCore;
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(feature = "rustls")]
|
||||
use crate::crypto::types::{Certificate, CertificateChain, PrivateKey};
|
||||
@@ -626,7 +626,7 @@ where
|
||||
#[non_exhaustive]
|
||||
pub enum ConfigError {
|
||||
/// Value exceeds supported bounds
|
||||
#[error(display = "value exceeds supported bounds")]
|
||||
#[error("value exceeds supported bounds")]
|
||||
OutOfBounds,
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use err_derive::Error;
|
||||
use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
use thiserror::Error;
|
||||
use tracing::{debug, error, trace, trace_span, warn};
|
||||
|
||||
use crate::{
|
||||
@@ -26,7 +26,7 @@ use crate::{
|
||||
ConnectionEvent, ConnectionEventInner, ConnectionId, EcnCodepoint, EndpointEvent,
|
||||
EndpointEventInner, IssuedCid,
|
||||
},
|
||||
transport_parameters::{self, TransportParameters},
|
||||
transport_parameters::TransportParameters,
|
||||
Dir, Frame, Side, StreamId, Transmit, TransportError, TransportErrorCode, VarInt,
|
||||
LOC_CID_COUNT, MAX_STREAM_COUNT, MIN_INITIAL_SIZE, MIN_MTU, RESET_TOKEN_SIZE,
|
||||
TIMER_GRANULARITY, VERSION,
|
||||
@@ -3010,25 +3010,25 @@ where
|
||||
#[derive(Debug, Error, Clone, PartialEq, Eq)]
|
||||
pub enum ConnectionError {
|
||||
/// The peer doesn't implement any supported version.
|
||||
#[error(display = "peer doesn't implement any supported version")]
|
||||
#[error("peer doesn't implement any supported version")]
|
||||
VersionMismatch,
|
||||
/// The peer violated the QUIC specification as understood by this implementation.
|
||||
#[error(display = "{}", _0)]
|
||||
TransportError(#[source] TransportError),
|
||||
#[error("{0}")]
|
||||
TransportError(#[from] TransportError),
|
||||
/// The peer's QUIC stack aborted the connection automatically.
|
||||
#[error(display = "aborted by peer: {}", 0)]
|
||||
#[error("aborted by peer: {}", 0)]
|
||||
ConnectionClosed(frame::ConnectionClose),
|
||||
/// The peer closed the connection.
|
||||
#[error(display = "closed by peer: {}", 0)]
|
||||
#[error("closed by peer: {}", 0)]
|
||||
ApplicationClosed(frame::ApplicationClose),
|
||||
/// The peer is unable to continue processing this connection, usually due to having restarted.
|
||||
#[error(display = "reset by peer")]
|
||||
#[error("reset by peer")]
|
||||
Reset,
|
||||
/// The peer has become unreachable.
|
||||
#[error(display = "timed out")]
|
||||
#[error("timed out")]
|
||||
TimedOut,
|
||||
/// The local application closed the connection.
|
||||
#[error(display = "closed")]
|
||||
#[error("closed")]
|
||||
LocallyClosed,
|
||||
}
|
||||
|
||||
@@ -3055,12 +3055,6 @@ impl From<ConnectionError> for io::Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<transport_parameters::Error> for ConnectionError {
|
||||
fn from(e: transport_parameters::Error) -> Self {
|
||||
TransportError::from(e).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
enum State {
|
||||
Handshake(state::Handshake),
|
||||
@@ -3223,16 +3217,16 @@ const MIN_PACKET_SPACE: usize = 40;
|
||||
#[derive(Debug, Error, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub enum SendDatagramError {
|
||||
/// The peer does not support receiving datagram frames
|
||||
#[error(display = "datagrams not supported by peer")]
|
||||
#[error("datagrams not supported by peer")]
|
||||
UnsupportedByPeer,
|
||||
/// Datagram support is disabled locally
|
||||
#[error(display = "datagram support disabled")]
|
||||
#[error("datagram support disabled")]
|
||||
Disabled,
|
||||
/// The datagram is larger than the connection can currently accommodate
|
||||
///
|
||||
/// Indicates that the path MTU minus overhead or the limit advertised by the peer has been
|
||||
/// exceeded.
|
||||
#[error(display = "datagram too large")]
|
||||
#[error("datagram too large")]
|
||||
TooLarge,
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::{BufMut, Bytes};
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
use tracing::{debug, trace};
|
||||
|
||||
use super::{
|
||||
@@ -922,7 +922,7 @@ pub enum WriteError {
|
||||
/// be generated, indicating that retrying the write might succeed.
|
||||
///
|
||||
/// [`StreamEvent::Writable`]: crate::StreamEvent::Writable
|
||||
#[error(display = "unable to accept further writes")]
|
||||
#[error("unable to accept further writes")]
|
||||
Blocked,
|
||||
/// The peer is no longer accepting data on this stream, and it has been implicitly reset. The
|
||||
/// stream cannot be finished or further written to.
|
||||
@@ -930,13 +930,13 @@ pub enum WriteError {
|
||||
/// Carries an application-defined error code.
|
||||
///
|
||||
/// [`StreamEvent::Finished`]: crate::StreamEvent::Finished
|
||||
#[error(display = "stopped by peer: code {}", 0)]
|
||||
#[error("stopped by peer: code {}", 0)]
|
||||
Stopped(VarInt),
|
||||
/// Unknown stream
|
||||
///
|
||||
/// Occurs when attempting to access a stream after finishing it or observing that it has been
|
||||
/// stopped.
|
||||
#[error(display = "unknown stream")]
|
||||
#[error("unknown stream")]
|
||||
UnknownStream,
|
||||
}
|
||||
|
||||
@@ -1081,24 +1081,24 @@ pub enum ReadError {
|
||||
///
|
||||
/// If more data on this stream is received from the peer, an `Event::StreamReadable` will be
|
||||
/// generated for this stream, indicating that retrying the read might succeed.
|
||||
#[error(display = "blocked")]
|
||||
#[error("blocked")]
|
||||
Blocked,
|
||||
/// The peer abandoned transmitting data on this stream.
|
||||
///
|
||||
/// Carries an application-defined error code.
|
||||
#[error(display = "reset by peer: code {}", 0)]
|
||||
#[error("reset by peer: code {}", 0)]
|
||||
Reset(VarInt),
|
||||
/// Unknown stream
|
||||
///
|
||||
/// Occurs when attempting to access a stream after stopping it, or observing that it has been
|
||||
/// finished or reset.
|
||||
#[error(display = "unknown stream")]
|
||||
#[error("unknown stream")]
|
||||
UnknownStream,
|
||||
/// Attempted an ordered read following an unordered read
|
||||
///
|
||||
/// Performing an unordered read allows discontinuities to arise in the receive buffer of a
|
||||
/// stream which cannot be recovered, making further ordered reads impossible.
|
||||
#[error(display = "ordered read after unordered read")]
|
||||
#[error("ordered read after unordered read")]
|
||||
IllegalOrderedRead,
|
||||
}
|
||||
|
||||
@@ -1144,10 +1144,10 @@ pub enum FinishError {
|
||||
/// Carries an application-defined error code.
|
||||
///
|
||||
/// [`StreamEvent::Finished`]: crate::StreamEvent::Finished
|
||||
#[error(display = "stopped by peer: code {}", 0)]
|
||||
#[error("stopped by peer: code {}", 0)]
|
||||
Stopped(VarInt),
|
||||
/// The stream has not yet been created or was already finished or stopped.
|
||||
#[error(display = "unknown stream")]
|
||||
#[error("unknown stream")]
|
||||
UnknownStream,
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use err_derive::Error;
|
||||
use rand::{rngs::StdRng, Rng, RngCore, SeedableRng};
|
||||
use slab::Slab;
|
||||
use thiserror::Error;
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
use crate::{
|
||||
@@ -807,18 +807,18 @@ pub enum ConnectError {
|
||||
/// The endpoint can no longer create new connections
|
||||
///
|
||||
/// Indicates that a necessary component of the endpoint has been dropped or otherwise disabled.
|
||||
#[error(display = "endpoint stopping")]
|
||||
#[error("endpoint stopping")]
|
||||
EndpointStopping,
|
||||
/// The number of active connections on the local endpoint is at the limit
|
||||
///
|
||||
/// Try using longer connection IDs.
|
||||
#[error(display = "too many connections")]
|
||||
#[error("too many connections")]
|
||||
TooManyConnections,
|
||||
/// The domain name supplied was malformed
|
||||
#[error(display = "invalid DNS name: {}", _0)]
|
||||
#[error("invalid DNS name: {0}")]
|
||||
InvalidDnsName(String),
|
||||
/// The transport configuration was invalid
|
||||
#[error(display = "transport configuration error: {}", _0)]
|
||||
#[error("transport configuration error: {0}")]
|
||||
Config(#[source] ConfigError),
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{cmp::Ordering, io, ops::Range, str};
|
||||
|
||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
coding::{self, BufExt, BufMutExt},
|
||||
@@ -711,13 +711,13 @@ pub(crate) enum LongType {
|
||||
|
||||
#[derive(Debug, Error, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
pub(crate) enum PacketDecodeError {
|
||||
#[error(display = "unsupported version {:x}", version)]
|
||||
#[error("unsupported version {version:x}")]
|
||||
UnsupportedVersion {
|
||||
src_cid: ConnectionId,
|
||||
dst_cid: ConnectionId,
|
||||
version: u32,
|
||||
},
|
||||
#[error(display = "invalid header: {}", _0)]
|
||||
#[error("invalid header: {0}")]
|
||||
InvalidHeader(&'static str),
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::{buf::ext::BufExt as _, Buf, BufMut};
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
cid_generator::ConnectionIdGenerator,
|
||||
@@ -246,10 +246,10 @@ impl PreferredAddress {
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Error)]
|
||||
pub enum Error {
|
||||
/// Parameters that are semantically invalid
|
||||
#[error(display = "parameter had illegal value")]
|
||||
#[error("parameter had illegal value")]
|
||||
IllegalValue,
|
||||
/// Catch-all error for problems while decoding transport parameters
|
||||
#[error(display = "parameters were malformed")]
|
||||
#[error("parameters were malformed")]
|
||||
Malformed,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{convert::TryInto, fmt};
|
||||
|
||||
use bytes::{Buf, BufMut};
|
||||
use err_derive::Error;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::coding::{self, Codec, UnexpectedEnd};
|
||||
|
||||
@@ -141,7 +141,7 @@ impl Arbitrary for VarInt {
|
||||
|
||||
/// Error returned when constructing a `VarInt` from a value >= 2^62
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Error)]
|
||||
#[error(display = "value too large for varint encoding")]
|
||||
#[error("value too large for varint encoding")]
|
||||
pub struct VarIntBoundsExceeded;
|
||||
|
||||
impl Codec for VarInt {
|
||||
|
||||
+1
-1
@@ -28,12 +28,12 @@ maintenance = { status = "experimental" }
|
||||
|
||||
[dependencies]
|
||||
bytes = "0.5.2"
|
||||
err-derive = "0.2.3"
|
||||
futures = "0.3.1"
|
||||
libc = "0.2.69"
|
||||
mio = "0.6"
|
||||
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.6.1" }
|
||||
rustls = { git = "https://github.com/ctz/rustls", rev = "fee894f7e030", features = ["quic"], optional = true }
|
||||
thiserror = "1.0.21"
|
||||
tracing = "0.1.10"
|
||||
tokio = { version = "0.2.6", features = ["rt-core", "io-driver", "time"] }
|
||||
webpki = { version = "0.21", optional = true }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{io, net::SocketAddr, str, sync::Arc};
|
||||
use std::{io, net::SocketAddr, sync::Arc};
|
||||
|
||||
use err_derive::Error;
|
||||
use proto::generic::{ClientConfig, EndpointConfig, ServerConfig};
|
||||
use thiserror::Error;
|
||||
use tracing::error;
|
||||
|
||||
use crate::{
|
||||
@@ -119,7 +119,7 @@ where
|
||||
#[derive(Debug, Error)]
|
||||
pub enum EndpointError {
|
||||
/// An error during setup of the underlying UDP socket.
|
||||
#[error(display = "failed to set up UDP socket: {}", _0)]
|
||||
#[error("failed to set up UDP socket: {0}")]
|
||||
Socket(io::Error),
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ use std::{
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use err_derive::Error;
|
||||
use futures::{
|
||||
channel::{mpsc, oneshot},
|
||||
FutureExt, StreamExt,
|
||||
};
|
||||
use proto::{ConnectionError, ConnectionHandle, Dir, StreamEvent, StreamId};
|
||||
use thiserror::Error;
|
||||
use tokio::time::{delay_until, Delay, Instant as TokioInstant};
|
||||
use tracing::info_span;
|
||||
|
||||
@@ -984,18 +984,18 @@ where
|
||||
#[derive(Debug, Error, Clone, Eq, PartialEq)]
|
||||
pub enum SendDatagramError {
|
||||
/// The peer does not support receiving datagram frames
|
||||
#[error(display = "datagrams not supported by peer")]
|
||||
#[error("datagrams not supported by peer")]
|
||||
UnsupportedByPeer,
|
||||
/// Datagram support is disabled locally
|
||||
#[error(display = "datagram support disabled")]
|
||||
#[error("datagram support disabled")]
|
||||
Disabled,
|
||||
/// The datagram is larger than the connection can currently accommodate
|
||||
///
|
||||
/// Indicates that the path MTU minus overhead or the limit advertised by the peer has been
|
||||
/// exceeded.
|
||||
#[error(display = "datagram too large")]
|
||||
#[error("datagram too large")]
|
||||
TooLarge,
|
||||
/// The connection was closed
|
||||
#[error(display = "connection closed: {}", _0)]
|
||||
#[error("connection closed: {0}")]
|
||||
ConnectionClosed(ConnectionError),
|
||||
}
|
||||
|
||||
+18
-25
@@ -3,18 +3,17 @@ use std::{
|
||||
io,
|
||||
mem::MaybeUninit,
|
||||
pin::Pin,
|
||||
str,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use err_derive::Error;
|
||||
use futures::{
|
||||
channel::oneshot,
|
||||
io::{AsyncRead, AsyncWrite},
|
||||
ready, FutureExt,
|
||||
};
|
||||
use proto::{ConnectionError, FinishError, StreamId};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{connection::ConnectionRef, VarInt};
|
||||
|
||||
@@ -536,19 +535,13 @@ where
|
||||
#[derive(Debug, Error, Clone, PartialEq, Eq)]
|
||||
pub enum ReadToEndError {
|
||||
/// An error occurred during reading
|
||||
#[error(display = "read error: {}", 0)]
|
||||
Read(ReadError),
|
||||
#[error("read error: {0}")]
|
||||
Read(#[from] ReadError),
|
||||
/// The stream is larger than the user-supplied limit
|
||||
#[error(display = "stream too long")]
|
||||
#[error("stream too long")]
|
||||
TooLong,
|
||||
}
|
||||
|
||||
impl From<ReadError> for ReadToEndError {
|
||||
fn from(x: ReadError) -> Self {
|
||||
ReadToEndError::Read(x)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> AsyncRead for RecvStream<S>
|
||||
where
|
||||
S: proto::crypto::Session,
|
||||
@@ -607,19 +600,19 @@ pub enum ReadError {
|
||||
/// The peer abandoned transmitting data on this stream.
|
||||
///
|
||||
/// Carries an application-defined error code.
|
||||
#[error(display = "stream reset by peer: error {}", 0)]
|
||||
#[error("stream reset by peer: error {0}")]
|
||||
Reset(VarInt),
|
||||
/// The connection was closed.
|
||||
#[error(display = "connection closed: {}", _0)]
|
||||
#[error("connection closed: {0}")]
|
||||
ConnectionClosed(ConnectionError),
|
||||
/// Unknown stream
|
||||
#[error(display = "unknown stream")]
|
||||
#[error("unknown stream")]
|
||||
UnknownStream,
|
||||
/// Attempted an ordered read following an unordered read
|
||||
///
|
||||
/// Performing an unordered read allows discontinuities to arise in the receive buffer of a
|
||||
/// stream which cannot be recovered, making further ordered reads impossible.
|
||||
#[error(display = "ordered read after unordered read")]
|
||||
#[error("ordered read after unordered read")]
|
||||
IllegalOrderedRead,
|
||||
/// This was a 0-RTT stream and the server rejected it.
|
||||
///
|
||||
@@ -627,7 +620,7 @@ pub enum ReadError {
|
||||
/// [`Connecting::into_0rtt()`].
|
||||
///
|
||||
/// [`Connecting::into_0rtt()`]: crate::generic::Connecting::into_0rtt()
|
||||
#[error(display = "0-RTT rejected")]
|
||||
#[error("0-RTT rejected")]
|
||||
ZeroRttRejected,
|
||||
}
|
||||
|
||||
@@ -652,13 +645,13 @@ pub enum WriteError {
|
||||
/// The peer is no longer accepting data on this stream.
|
||||
///
|
||||
/// Carries an application-defined error code.
|
||||
#[error(display = "sending stopped by peer: error {}", 0)]
|
||||
#[error("sending stopped by peer: error {0}")]
|
||||
Stopped(VarInt),
|
||||
/// The connection was closed.
|
||||
#[error(display = "connection closed: {}", _0)]
|
||||
#[error("connection closed: {0}")]
|
||||
ConnectionClosed(ConnectionError),
|
||||
/// Unknown stream
|
||||
#[error(display = "unknown stream")]
|
||||
#[error("unknown stream")]
|
||||
UnknownStream,
|
||||
/// This was a 0-RTT stream and the server rejected it.
|
||||
///
|
||||
@@ -666,7 +659,7 @@ pub enum WriteError {
|
||||
/// [`Connecting::into_0rtt()`].
|
||||
///
|
||||
/// [`Connecting::into_0rtt()`]: crate::generic::Connecting::into_0rtt()
|
||||
#[error(display = "0-RTT rejected")]
|
||||
#[error("0-RTT rejected")]
|
||||
ZeroRttRejected,
|
||||
}
|
||||
|
||||
@@ -674,10 +667,10 @@ pub enum WriteError {
|
||||
#[derive(Debug, Error, Clone, PartialEq, Eq)]
|
||||
pub enum StoppedError {
|
||||
/// The connection was closed.
|
||||
#[error(display = "connection closed: {}", _0)]
|
||||
#[error("connection closed: {0}")]
|
||||
ConnectionClosed(ConnectionError),
|
||||
/// Unknown stream
|
||||
#[error(display = "unknown stream")]
|
||||
#[error("unknown stream")]
|
||||
UnknownStream,
|
||||
/// This was a 0-RTT stream and the server rejected it.
|
||||
///
|
||||
@@ -685,7 +678,7 @@ pub enum StoppedError {
|
||||
/// [`Connecting::into_0rtt()`].
|
||||
///
|
||||
/// [`Connecting::into_0rtt()`]: crate::generic::Connecting::into_0rtt()
|
||||
#[error(display = "0-RTT rejected")]
|
||||
#[error("0-RTT rejected")]
|
||||
ZeroRttRejected,
|
||||
}
|
||||
|
||||
@@ -760,10 +753,10 @@ where
|
||||
#[derive(Debug, Error, Clone, PartialEq, Eq)]
|
||||
pub enum ReadExactError {
|
||||
/// The stream finished before all bytes were read
|
||||
#[error(display = "stream finished early")]
|
||||
#[error("stream finished early")]
|
||||
FinishedEarly,
|
||||
/// A read error occurred
|
||||
#[error(display = "{}", 0)]
|
||||
#[error("{0}")]
|
||||
ReadError(ReadError),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user