1- use dash_sdk:: { error:: StateTransitionBroadcastError , Error as SdkError } ;
21use dash_sdk:: dpp:: ProtocolError ;
2+ use dash_sdk:: Error :: { EpochNotFound , TotalCreditsNotFound } ;
3+ use dash_sdk:: { error:: StateTransitionBroadcastError , Error as SdkError } ;
34use rs_dapi_client:: CanRetry ;
45use std:: fmt:: Display ;
56use wasm_bindgen:: prelude:: wasm_bindgen;
6- use dash_sdk:: Error :: { EpochNotFound , TotalCreditsNotFound } ;
77
88/// Structured error surfaced to JS consumers
99#[ wasm_bindgen]
@@ -53,7 +53,12 @@ pub struct WasmSdkError {
5353// wasm-bindgen getters defined below in the second impl block
5454
5555impl WasmSdkError {
56- fn new < M : Into < String > > ( kind : WasmSdkErrorKind , message : M , code : Option < i32 > , retriable : bool ) -> Self {
56+ fn new < M : Into < String > > (
57+ kind : WasmSdkErrorKind ,
58+ message : M ,
59+ code : Option < i32 > ,
60+ retriable : bool ,
61+ ) -> Self {
5762 Self {
5863 kind,
5964 message : message. into ( ) ,
@@ -87,28 +92,46 @@ impl From<SdkError> for WasmSdkError {
8792 AlreadyExists ( msg) => Self :: new ( WasmSdkErrorKind :: AlreadyExists , msg, None , retriable) ,
8893 Config ( msg) => Self :: new ( WasmSdkErrorKind :: Config , msg, None , retriable) ,
8994 Drive ( e) => Self :: new ( WasmSdkErrorKind :: Drive , e. to_string ( ) , None , retriable) ,
90- DriveProofError ( e, _proof, _block_info) => {
91- Self :: new ( WasmSdkErrorKind :: DriveProofError , e. to_string ( ) , None , retriable)
92- }
95+ DriveProofError ( e, _proof, _block_info) => Self :: new (
96+ WasmSdkErrorKind :: DriveProofError ,
97+ e. to_string ( ) ,
98+ None ,
99+ retriable,
100+ ) ,
93101 Protocol ( e) => Self :: new ( WasmSdkErrorKind :: Protocol , e. to_string ( ) , None , retriable) ,
94102 Proof ( e) => Self :: new ( WasmSdkErrorKind :: Proof , e. to_string ( ) , None , retriable) ,
95- InvalidProvedResponse ( msg) => {
96- Self :: new ( WasmSdkErrorKind :: InvalidProvedResponse , msg, None , retriable)
97- }
98- DapiClientError ( e) => {
99- Self :: new ( WasmSdkErrorKind :: DapiClientError , e. to_string ( ) , None , retriable)
100- }
103+ InvalidProvedResponse ( msg) => Self :: new (
104+ WasmSdkErrorKind :: InvalidProvedResponse ,
105+ msg,
106+ None ,
107+ retriable,
108+ ) ,
109+ DapiClientError ( e) => Self :: new (
110+ WasmSdkErrorKind :: DapiClientError ,
111+ e. to_string ( ) ,
112+ None ,
113+ retriable,
114+ ) ,
101115 #[ cfg( feature = "mocks" ) ]
102- DapiMocksError ( e) => {
103- Self :: new ( WasmSdkErrorKind :: DapiMocksError , e. to_string ( ) , None , retriable)
104- }
116+ DapiMocksError ( e) => Self :: new (
117+ WasmSdkErrorKind :: DapiMocksError ,
118+ e. to_string ( ) ,
119+ None ,
120+ retriable,
121+ ) ,
105122 CoreError ( e) => Self :: new ( WasmSdkErrorKind :: CoreError , e. to_string ( ) , None , retriable) ,
106- MerkleBlockError ( e) => {
107- Self :: new ( WasmSdkErrorKind :: MerkleBlockError , e. to_string ( ) , None , retriable)
108- }
109- CoreClientError ( e) => {
110- Self :: new ( WasmSdkErrorKind :: CoreClientError , e. to_string ( ) , None , retriable)
111- }
123+ MerkleBlockError ( e) => Self :: new (
124+ WasmSdkErrorKind :: MerkleBlockError ,
125+ e. to_string ( ) ,
126+ None ,
127+ retriable,
128+ ) ,
129+ CoreClientError ( e) => Self :: new (
130+ WasmSdkErrorKind :: CoreClientError ,
131+ e. to_string ( ) ,
132+ None ,
133+ retriable,
134+ ) ,
112135 MissingDependency ( kind, id) => Self :: new (
113136 WasmSdkErrorKind :: MissingDependency ,
114137 format ! ( "Required {} not found: {}" , kind, id) ,
@@ -129,7 +152,11 @@ impl From<SdkError> for WasmSdkError {
129152 ) ,
130153 TimeoutReached ( duration, msg) => Self :: new (
131154 WasmSdkErrorKind :: TimeoutReached ,
132- format ! ( "SDK operation timeout {} secs reached: {}" , duration. as_secs( ) , msg) ,
155+ format ! (
156+ "SDK operation timeout {} secs reached: {}" ,
157+ duration. as_secs( ) ,
158+ msg
159+ ) ,
133160 None ,
134161 retriable,
135162 ) ,
0 commit comments