@@ -89,7 +89,7 @@ impl Display for ClientJsonrpcRequest {
8989}
9090
9191impl FromStr for ClientJsonrpcRequest {
92- type Err = serde_json :: error :: Error ;
92+ type Err = JsonrpcErrorError ;
9393
9494 /// Parses a JSON-RPC request from a string.
9595 ///
@@ -101,7 +101,7 @@ impl FromStr for ClientJsonrpcRequest {
101101 ///
102102 /// # Returns
103103 /// * `Ok(ClientJsonrpcRequest)` if parsing is successful.
104- /// * `Err(serde_json::error::Error )` if the string is not valid JSON.
104+ /// * `Err(JsonrpcErrorError )` if the string is not valid JSON.
105105 ///
106106 /// # Example
107107 /// ```
@@ -114,6 +114,7 @@ impl FromStr for ClientJsonrpcRequest {
114114 /// ```
115115 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
116116 serde_json:: from_str ( s)
117+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
117118 }
118119}
119120
@@ -210,10 +211,11 @@ impl Display for ClientJsonrpcNotification {
210211}
211212
212213impl FromStr for ClientJsonrpcNotification {
213- type Err = serde_json :: error :: Error ;
214+ type Err = JsonrpcErrorError ;
214215
215216 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
216217 serde_json:: from_str ( s)
218+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
217219 }
218220}
219221
@@ -297,10 +299,11 @@ impl Display for ClientJsonrpcResponse {
297299}
298300
299301impl FromStr for ClientJsonrpcResponse {
300- type Err = serde_json :: error :: Error ;
302+ type Err = JsonrpcErrorError ;
301303
302304 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
303305 serde_json:: from_str ( s)
306+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
304307 }
305308}
306309//*******************************//
@@ -349,10 +352,11 @@ impl<'de> serde::Deserialize<'de> for ResultFromClient {
349352//*******************************//
350353
351354impl FromStr for ClientMessage {
352- type Err = serde_json :: error :: Error ;
355+ type Err = JsonrpcErrorError ;
353356
354357 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
355358 serde_json:: from_str ( s)
359+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
356360 }
357361}
358362
@@ -382,10 +386,11 @@ pub enum ServerMessage {
382386}
383387
384388impl FromStr for ServerMessage {
385- type Err = serde_json :: error :: Error ;
389+ type Err = JsonrpcErrorError ;
386390
387391 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
388392 serde_json:: from_str ( s)
393+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
389394 }
390395}
391396
@@ -436,10 +441,11 @@ impl Display for ServerJsonrpcRequest {
436441}
437442
438443impl FromStr for ServerJsonrpcRequest {
439- type Err = serde_json :: error :: Error ;
444+ type Err = JsonrpcErrorError ;
440445
441446 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
442447 serde_json:: from_str ( s)
448+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
443449 }
444450}
445451//*************************//
@@ -535,10 +541,11 @@ impl Display for ServerJsonrpcNotification {
535541}
536542
537543impl FromStr for ServerJsonrpcNotification {
538- type Err = serde_json :: error :: Error ;
544+ type Err = JsonrpcErrorError ;
539545
540546 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
541547 serde_json:: from_str ( s)
548+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
542549 }
543550}
544551//*******************************//
@@ -621,10 +628,11 @@ impl Display for ServerJsonrpcResponse {
621628}
622629
623630impl FromStr for ServerJsonrpcResponse {
624- type Err = serde_json :: error :: Error ;
631+ type Err = JsonrpcErrorError ;
625632
626633 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
627634 serde_json:: from_str ( s)
635+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
628636 }
629637}
630638//*******************************//
@@ -690,10 +698,11 @@ impl Display for JsonrpcError {
690698}
691699
692700impl FromStr for JsonrpcError {
693- type Err = serde_json :: error :: Error ;
701+ type Err = JsonrpcErrorError ;
694702
695703 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
696704 serde_json:: from_str ( s)
705+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
697706 }
698707}
699708
@@ -1386,9 +1395,10 @@ impl Display for JsonrpcErrorError {
13861395 }
13871396}
13881397impl FromStr for JsonrpcErrorError {
1389- type Err = serde_json :: error :: Error ;
1398+ type Err = JsonrpcErrorError ;
13901399 fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
13911400 serde_json:: from_str ( s)
1401+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
13921402 }
13931403}
13941404/// Constructs a new JsonrpcError using the provided arguments.
0 commit comments