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 @@ -67,8 +67,8 @@ impl wasi_outbound_http::WasiOutboundHttp for OutboundHttp {
67
67
. headers ( headers)
68
68
. body ( body)
69
69
. send ( ) ,
70
- ) ? ;
71
-
70
+ ) ;
71
+ let res = log_request_error ( res ) ? ;
72
72
Response :: try_from ( res)
73
73
} ) )
74
74
. map_err ( |_| HttpError :: RuntimeError ) ?,
@@ -77,13 +77,39 @@ impl wasi_outbound_http::WasiOutboundHttp for OutboundHttp {
77
77
. request ( method, url)
78
78
. headers ( headers)
79
79
. body ( body)
80
- . send ( ) ?;
80
+ . send ( ) ;
81
+ let res = log_request_error ( res) ?;
81
82
Ok ( Response :: try_from ( res) ?)
82
83
}
83
84
}
84
85
}
85
86
}
86
87
88
+ fn log_request_error < R > ( response : Result < R , reqwest:: Error > ) -> Result < R , reqwest:: Error > {
89
+ if let Err ( e) = & response {
90
+ let error_desc = if e. is_timeout ( ) {
91
+ "timeout error"
92
+ } else if e. is_connect ( ) {
93
+ "connection error"
94
+ } else if e. is_body ( ) || e. is_decode ( ) {
95
+ "message body error"
96
+ } else if e. is_request ( ) {
97
+ "request error"
98
+ } else {
99
+ "error"
100
+ } ;
101
+ tracing:: warn!(
102
+ "Outbound HTTP {}: URL {}, error detail {:?}" ,
103
+ error_desc,
104
+ e. url( )
105
+ . map( |u| u. to_string( ) )
106
+ . unwrap_or_else( || "<unknown>" . to_owned( ) ) ,
107
+ e
108
+ ) ;
109
+ }
110
+ response
111
+ }
112
+
87
113
impl From < Method > for http:: Method {
88
114
fn from ( m : Method ) -> Self {
89
115
match m {
You can’t perform that action at this time.
0 commit comments