File tree Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Expand file tree Collapse file tree 1 file changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,8 @@ impl wasi_outbound_http::WasiOutboundHttp for OutboundHttp {
88
88
. headers ( headers)
89
89
. body ( body)
90
90
. send ( ) ,
91
- ) ? ;
92
-
91
+ ) ;
92
+ let res = log_request_error ( res ) ? ;
93
93
Response :: try_from ( res)
94
94
} ) )
95
95
. map_err ( |_| HttpError :: RuntimeError ) ?,
@@ -98,13 +98,39 @@ impl wasi_outbound_http::WasiOutboundHttp for OutboundHttp {
98
98
. request ( method, url)
99
99
. headers ( headers)
100
100
. body ( body)
101
- . send ( ) ?;
101
+ . send ( ) ;
102
+ let res = log_request_error ( res) ?;
102
103
Ok ( Response :: try_from ( res) ?)
103
104
}
104
105
}
105
106
}
106
107
}
107
108
109
+ fn log_request_error < R > ( response : Result < R , reqwest:: Error > ) -> Result < R , reqwest:: Error > {
110
+ if let Err ( e) = & response {
111
+ let error_desc = if e. is_timeout ( ) {
112
+ "timeout error"
113
+ } else if e. is_connect ( ) {
114
+ "connection error"
115
+ } else if e. is_body ( ) || e. is_decode ( ) {
116
+ "message body error"
117
+ } else if e. is_request ( ) {
118
+ "request error"
119
+ } else {
120
+ "error"
121
+ } ;
122
+ tracing:: warn!(
123
+ "Outbound HTTP {}: URL {}, error detail {:?}" ,
124
+ error_desc,
125
+ e. url( )
126
+ . map( |u| u. to_string( ) )
127
+ . unwrap_or_else( || "<unknown>" . to_owned( ) ) ,
128
+ e
129
+ ) ;
130
+ }
131
+ response
132
+ }
133
+
108
134
impl From < Method > for http:: Method {
109
135
fn from ( m : Method ) -> Self {
110
136
match m {
You can’t perform that action at this time.
0 commit comments