@@ -89,7 +89,7 @@ impl Display for ClientJsonrpcRequest {
89
89
}
90
90
91
91
impl FromStr for ClientJsonrpcRequest {
92
- type Err = serde_json :: error :: Error ;
92
+ type Err = JsonrpcErrorError ;
93
93
94
94
/// Parses a JSON-RPC request from a string.
95
95
///
@@ -101,7 +101,7 @@ impl FromStr for ClientJsonrpcRequest {
101
101
///
102
102
/// # Returns
103
103
/// * `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.
105
105
///
106
106
/// # Example
107
107
/// ```
@@ -114,6 +114,7 @@ impl FromStr for ClientJsonrpcRequest {
114
114
/// ```
115
115
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
116
116
serde_json:: from_str ( s)
117
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
117
118
}
118
119
}
119
120
@@ -210,10 +211,11 @@ impl Display for ClientJsonrpcNotification {
210
211
}
211
212
212
213
impl FromStr for ClientJsonrpcNotification {
213
- type Err = serde_json :: error :: Error ;
214
+ type Err = JsonrpcErrorError ;
214
215
215
216
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
216
217
serde_json:: from_str ( s)
218
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
217
219
}
218
220
}
219
221
@@ -297,10 +299,11 @@ impl Display for ClientJsonrpcResponse {
297
299
}
298
300
299
301
impl FromStr for ClientJsonrpcResponse {
300
- type Err = serde_json :: error :: Error ;
302
+ type Err = JsonrpcErrorError ;
301
303
302
304
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
303
305
serde_json:: from_str ( s)
306
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
304
307
}
305
308
}
306
309
//*******************************//
@@ -349,10 +352,11 @@ impl<'de> serde::Deserialize<'de> for ResultFromClient {
349
352
//*******************************//
350
353
351
354
impl FromStr for ClientMessage {
352
- type Err = serde_json :: error :: Error ;
355
+ type Err = JsonrpcErrorError ;
353
356
354
357
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
355
358
serde_json:: from_str ( s)
359
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
356
360
}
357
361
}
358
362
@@ -382,10 +386,11 @@ pub enum ServerMessage {
382
386
}
383
387
384
388
impl FromStr for ServerMessage {
385
- type Err = serde_json :: error :: Error ;
389
+ type Err = JsonrpcErrorError ;
386
390
387
391
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
388
392
serde_json:: from_str ( s)
393
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
389
394
}
390
395
}
391
396
@@ -436,10 +441,11 @@ impl Display for ServerJsonrpcRequest {
436
441
}
437
442
438
443
impl FromStr for ServerJsonrpcRequest {
439
- type Err = serde_json :: error :: Error ;
444
+ type Err = JsonrpcErrorError ;
440
445
441
446
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
442
447
serde_json:: from_str ( s)
448
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
443
449
}
444
450
}
445
451
//*************************//
@@ -535,10 +541,11 @@ impl Display for ServerJsonrpcNotification {
535
541
}
536
542
537
543
impl FromStr for ServerJsonrpcNotification {
538
- type Err = serde_json :: error :: Error ;
544
+ type Err = JsonrpcErrorError ;
539
545
540
546
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
541
547
serde_json:: from_str ( s)
548
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
542
549
}
543
550
}
544
551
//*******************************//
@@ -621,10 +628,11 @@ impl Display for ServerJsonrpcResponse {
621
628
}
622
629
623
630
impl FromStr for ServerJsonrpcResponse {
624
- type Err = serde_json :: error :: Error ;
631
+ type Err = JsonrpcErrorError ;
625
632
626
633
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
627
634
serde_json:: from_str ( s)
635
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
628
636
}
629
637
}
630
638
//*******************************//
@@ -690,10 +698,11 @@ impl Display for JsonrpcError {
690
698
}
691
699
692
700
impl FromStr for JsonrpcError {
693
- type Err = serde_json :: error :: Error ;
701
+ type Err = JsonrpcErrorError ;
694
702
695
703
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
696
704
serde_json:: from_str ( s)
705
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
697
706
}
698
707
}
699
708
@@ -1386,9 +1395,10 @@ impl Display for JsonrpcErrorError {
1386
1395
}
1387
1396
}
1388
1397
impl FromStr for JsonrpcErrorError {
1389
- type Err = serde_json :: error :: Error ;
1398
+ type Err = JsonrpcErrorError ;
1390
1399
fn from_str ( s : & str ) -> std:: result:: Result < Self , Self :: Err > {
1391
1400
serde_json:: from_str ( s)
1401
+ . map_err ( |error| JsonrpcErrorError :: parse_error ( ) . with_data ( Some ( json ! ( { "details" : error. to_string( ) } ) ) ) )
1392
1402
}
1393
1403
}
1394
1404
/// Constructs a new JsonrpcError using the provided arguments.
0 commit comments