File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ pub trait TransportRequest: Clone + Send + Sync + Debug + Mockable {
4848/// Generic way to create a transport client from provided [Uri].
4949pub trait TransportClient : Send + Sized {
5050 /// Error type for the specific client.
51- type Error : CanRetry + Send + Debug + Mockable ;
51+ type Error : CanRetry + Send + Debug + Mockable + ' static ;
5252
5353 /// Build client using node's url.
5454 fn with_uri ( uri : Uri , pool : & ConnectionPool ) -> Result < Self , Self :: Error > ;
Original file line number Diff line number Diff line change 11//! Definitions of errors
2+
3+ use std:: any:: Any ;
24use std:: fmt:: Debug ;
35use std:: time:: Duration ;
46
57use dapi_grpc:: mock:: Mockable ;
8+ use dpp:: consensus:: ConsensusError ;
9+ use dpp:: serialization:: PlatformDeserializable ;
610use dpp:: version:: PlatformVersionError ;
711use dpp:: ProtocolError ;
812use rs_dapi_client:: { CanRetry , DapiClientError } ;
@@ -73,8 +77,24 @@ pub enum Error {
7377 StaleNode ( #[ from] StaleNodeError ) ,
7478}
7579
76- impl < T : Debug + Mockable > From < DapiClientError < T > > for Error {
80+ impl < T : Debug + Mockable + Any > From < DapiClientError < T > > for Error {
7781 fn from ( value : DapiClientError < T > ) -> Self {
82+ if let DapiClientError :: Transport ( ref t, _) = & value {
83+ if let Some ( status) = ( t as & dyn Any ) . downcast_ref :: < dapi_grpc:: tonic:: Status > ( ) {
84+ if let Some ( consensus_error_value) =
85+ status. metadata ( ) . get_bin ( "drive-error-data-bin" )
86+ {
87+ return ConsensusError :: deserialize_from_bytes (
88+ consensus_error_value. as_encoded_bytes ( ) ,
89+ )
90+ . map ( |consensus_error| {
91+ Error :: Protocol ( ProtocolError :: ConsensusError ( Box :: new ( consensus_error) ) )
92+ } )
93+ . unwrap_or_else ( Error :: Protocol ) ;
94+ }
95+ }
96+ }
97+
7898 Self :: DapiClientError ( format ! ( "{:?}" , value) )
7999 }
80100}
You can’t perform that action at this time.
0 commit comments