11use rama:: {
22 Layer , Service ,
3- error:: { BoxError , ErrorContext } ,
3+ error:: { BoxError , ErrorContext , ErrorExt , extra :: OpaqueError } ,
44 http:: {
55 Request , Response , StreamingBody ,
66 client:: {
@@ -15,7 +15,7 @@ use rama::{
1515 required_header:: AddRequiredRequestHeadersLayer ,
1616 } ,
1717 } ,
18- layer:: { HijackLayer , MapResultLayer , TimeoutLayer , layer_fn} ,
18+ layer:: { HijackLayer , MapErrLayer , MapResultLayer , TimeoutLayer , layer_fn} ,
1919 net:: {
2020 tls:: client:: ServerVerifyMode ,
2121 user:: { Basic , ProxyCredential } ,
@@ -53,7 +53,7 @@ mod writer;
5353
5454pub ( super ) async fn new (
5555 cfg : & SendCommand ,
56- ) -> Result < impl Service < Request , Output = Response , Error = BoxError > , BoxError > {
56+ ) -> Result < impl Service < Request , Output = Response , Error = OpaqueError > , BoxError > {
5757 let writer = writer:: try_new ( cfg) . await ?;
5858
5959 let inner_client = new_inner_client ( cfg) ?;
@@ -114,6 +114,7 @@ pub(super) async fn new(
114114 } ,
115115 SetProxyAuthHttpHeaderLayer :: default ( ) ,
116116 HijackLayer :: new ( cfg. curl , curl_writer:: CurlWriter { writer } ) ,
117+ MapErrLayer :: into_box_error ( ) ,
117118 layer_fn ( move |svc| logger_headers_res:: ResponseHeaderLogger {
118119 inner : svc,
119120 show_headers,
@@ -125,7 +126,7 @@ pub(super) async fn new(
125126
126127fn new_inner_client (
127128 cfg : & SendCommand ,
128- ) -> Result < impl Service < Request , Output = Response , Error = BoxError > + Clone , BoxError > {
129+ ) -> Result < impl Service < Request , Output = Response , Error = OpaqueError > + Clone , BoxError > {
129130 let mut tls_config = if cfg. emulate {
130131 TlsConnectorDataBuilder :: new ( )
131132 } else {
@@ -209,13 +210,13 @@ pub(super) struct VerboseLogs;
209210
210211fn map_internal_client_error < E , Body > (
211212 result : Result < Response < Body > , E > ,
212- ) -> Result < Response , BoxError >
213+ ) -> Result < Response , OpaqueError >
213214where
214215 E : Into < BoxError > ,
215216 Body : StreamingBody < Data = rama:: bytes:: Bytes , Error : Into < BoxError > > + Send + Sync + ' static ,
216217{
217218 match result {
218219 Ok ( response) => Ok ( response. map ( rama:: http:: Body :: new) ) ,
219- Err ( err) => Err ( err. into ( ) ) ,
220+ Err ( err) => Err ( err. into_opaque_error ( ) ) ,
220221 }
221222}
0 commit comments