11use std:: error:: Error as StdError ;
2- use std:: fmt:: { self , Error as FormatError } ;
2+ use std:: fmt;
33use std:: io:: Error as IoError ;
44
55#[ cfg( feature = "http" ) ]
@@ -31,10 +31,6 @@ pub type Result<T, E = Error> = StdResult<T, E>;
3131#[ derive( Debug ) ]
3232#[ non_exhaustive]
3333pub enum Error {
34- /// An error while decoding a payload.
35- Decode ( & ' static str , Value ) ,
36- /// There was an error with a format.
37- Format ( FormatError ) ,
3834 /// An [`std::io`] error.
3935 Io ( IoError ) ,
4036 #[ cfg_attr( not( feature = "simd_json" ) , doc = "An error from the [`serde_json`] crate." ) ]
@@ -44,20 +40,6 @@ pub enum Error {
4440 ///
4541 /// [`model`]: crate::model
4642 Model ( ModelError ) ,
47- /// The input is not in the specified range. Returned by [`GuildId::members`],
48- /// [`Guild::members`] and [`PartialGuild::members`]
49- ///
50- /// (param_name, value, range_min, range_max)
51- ///
52- /// [`GuildId::members`]: crate::model::id::GuildId::members
53- /// [`Guild::members`]: crate::model::guild::Guild::members
54- /// [`PartialGuild::members`]: crate::model::guild::PartialGuild::members
55- NotInRange ( & ' static str , u64 , u64 , u64 ) ,
56- /// Some other error. This is only used for "Expected value \<TYPE\>" errors, when a more
57- /// detailed error can not be easily provided via the [`Error::Decode`] variant.
58- Other ( & ' static str ) ,
59- /// An error from the [`url`] crate.
60- Url ( String ) ,
6143 /// A [client] error.
6244 ///
6345 /// [client]: crate::client
@@ -75,13 +57,7 @@ pub enum Error {
7557 Http ( HttpError ) ,
7658 /// An error from the `tungstenite` crate.
7759 #[ cfg( feature = "gateway" ) ]
78- Tungstenite ( TungsteniteError ) ,
79- }
80-
81- impl From < FormatError > for Error {
82- fn from ( e : FormatError ) -> Error {
83- Error :: Format ( e)
84- }
60+ Tungstenite ( Box < TungsteniteError > ) ,
8561}
8662
8763#[ cfg( feature = "gateway" ) ]
@@ -112,7 +88,7 @@ impl From<ModelError> for Error {
11288#[ cfg( feature = "gateway" ) ]
11389impl From < TungsteniteError > for Error {
11490 fn from ( e : TungsteniteError ) -> Error {
115- Error :: Tungstenite ( e )
91+ Error :: Tungstenite ( Box :: new ( e ) )
11692 }
11793}
11894
@@ -140,13 +116,9 @@ impl From<ReqwestError> for Error {
140116impl fmt:: Display for Error {
141117 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
142118 match self {
143- Self :: Decode ( msg, _) | Self :: Other ( msg) => f. write_str ( msg) ,
144- Self :: NotInRange ( ..) => f. write_str ( "Input is not in the specified range" ) ,
145- Self :: Format ( inner) => fmt:: Display :: fmt ( & inner, f) ,
146119 Self :: Io ( inner) => fmt:: Display :: fmt ( & inner, f) ,
147120 Self :: Json ( inner) => fmt:: Display :: fmt ( & inner, f) ,
148121 Self :: Model ( inner) => fmt:: Display :: fmt ( & inner, f) ,
149- Self :: Url ( msg) => f. write_str ( msg) ,
150122 #[ cfg( feature = "client" ) ]
151123 Self :: Client ( inner) => fmt:: Display :: fmt ( & inner, f) ,
152124 #[ cfg( feature = "gateway" ) ]
@@ -163,7 +135,6 @@ impl StdError for Error {
163135 #[ cfg_attr( feature = "tracing_instrument" , instrument) ]
164136 fn source ( & self ) -> Option < & ( dyn StdError + ' static ) > {
165137 match self {
166- Self :: Format ( inner) => Some ( inner) ,
167138 Self :: Io ( inner) => Some ( inner) ,
168139 Self :: Json ( inner) => Some ( inner) ,
169140 Self :: Model ( inner) => Some ( inner) ,
0 commit comments