@@ -6,11 +6,11 @@ pub enum Error {
66 TimedOut ,
77 StreamClosed ,
88 /// An invalid request parameter
9- InvalidParameter ( Box < dyn std:: error:: Error + Send + ' static > ) ,
9+ InvalidParameter ( Box < dyn std:: error:: Error + Send + Sync + ' static > ) ,
1010 /// The HTTP response could not be handled.
1111 UnexpectedResponse ( StatusCode ) ,
1212 /// An error reading from the HTTP response body.
13- HttpStream ( Box < dyn std:: error:: Error + Send + ' static > ) ,
13+ HttpStream ( Box < dyn std:: error:: Error + Send + Sync + ' static > ) ,
1414 /// The HTTP response stream ended
1515 Eof ,
1616 /// The HTTP response stream ended unexpectedly (e.g. in the
@@ -20,13 +20,32 @@ pub enum Error {
2020 InvalidLine ( String ) ,
2121 InvalidEvent ,
2222 /// Encountered a malformed Location header.
23- MalformedLocationHeader ( Box < dyn std:: error:: Error + Send + ' static > ) ,
23+ MalformedLocationHeader ( Box < dyn std:: error:: Error + Send + Sync + ' static > ) ,
2424 /// Reached maximum redirect limit after encountering Location headers.
2525 MaxRedirectLimitReached ( u32 ) ,
26- /// An unexpected failure occurred.
27- Unexpected ( Box < dyn std:: error:: Error + Send + ' static > ) ,
2826}
2927
28+ impl std:: fmt:: Display for Error {
29+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
30+ use Error :: * ;
31+ match self {
32+ TimedOut => write ! ( f, "timed out" ) ,
33+ StreamClosed => write ! ( f, "stream closed" ) ,
34+ InvalidParameter ( err) => write ! ( f, "invalid parameter: {err}" ) ,
35+ UnexpectedResponse ( status_code) => write ! ( f, "unexpected response: {status_code}" ) ,
36+ HttpStream ( err) => write ! ( f, "http error: {err}" ) ,
37+ Eof => write ! ( f, "eof" ) ,
38+ UnexpectedEof => write ! ( f, "unexpected eof" ) ,
39+ InvalidLine ( line) => write ! ( f, "invalid line: {line}" ) ,
40+ InvalidEvent => write ! ( f, "invalid event" ) ,
41+ MalformedLocationHeader ( err) => write ! ( f, "malformed header: {err}" ) ,
42+ MaxRedirectLimitReached ( limit) => write ! ( f, "maximum redirect limit reached: {limit}" ) ,
43+ }
44+ }
45+ }
46+
47+ impl std:: error:: Error for Error { }
48+
3049impl PartialEq < Error > for Error {
3150 fn eq ( & self , other : & Error ) -> bool {
3251 use Error :: * ;
@@ -50,19 +69,9 @@ impl Error {
5069 pub fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
5170 match self {
5271 Error :: HttpStream ( err) => Some ( err. as_ref ( ) ) ,
53- Error :: Unexpected ( err) => Some ( err. as_ref ( ) ) ,
5472 _ => None ,
5573 }
5674 }
5775}
5876
59- impl < E > From < E > for Error
60- where
61- E : std:: error:: Error + Send + ' static ,
62- {
63- fn from ( e : E ) -> Error {
64- Error :: Unexpected ( Box :: new ( e) )
65- }
66- }
67-
6877pub type Result < T > = std:: result:: Result < T , Error > ;
0 commit comments