@@ -4,6 +4,79 @@ The format is based on [Keep a Changelog].
4
4
5
5
[ Keep a Changelog ] : http://keepachangelog.com/en/1.0.0/
6
6
7
+ ## [ v0.18.0] - 2023-04-21
8
+
9
+ This is a breaking release that removes the ` CallError ` which was used to represent a JSON-RPC error object that
10
+ could happen during JSON-RPC method call and one could assign application specific error code, message and data in a
11
+ specific implementation.
12
+
13
+ Previously jsonrpsee provided ` CallError ` that could be converted to/from ` jsonrpsee::core::Error `
14
+ and in some scenarios the error code was automatically assigned by jsonrpsee. After jsonrpsee
15
+ added support for custom error types the ` CallError ` doesn't provide any benefit because one has to implement ` Into<ErrorObjectOwned> `
16
+ on the error type anyway.
17
+
18
+ Thus, ` jsonrpsee::core::Error ` can't be used in the proc macro API anymore and the type alias
19
+ ` RpcResult ` has been modified to ` Result<(), ErrorObjectOwned> ` instead.
20
+
21
+ Before it was possible to do:
22
+
23
+ ``` rust
24
+ #[derive(thiserror:: Error )]
25
+ enum Error {
26
+ A ,
27
+ B ,
28
+ }
29
+
30
+ #[rpc(server, client)]
31
+ pub trait Rpc
32
+ {
33
+ #[method(name = " getKeys" )]
34
+ async fn keys (& self ) -> Result <String , jsonrpsee :: core :: Error > {
35
+ Err (jsonrpsee :: core :: Error :: to_call_error (Error :: A ))
36
+ // or jsonrpsee::core::Error::Call(CallError::Custom(ErrorObject::owned(1, "a", None::<()>)))
37
+ }
38
+ }
39
+ ```
40
+
41
+ After this change one has to do:
42
+
43
+ ``` rust
44
+ pub enum Error {
45
+ A ,
46
+ B ,
47
+ }
48
+
49
+ impl From <Error > for ErrorObjectOwned {
50
+ fn from (e : Error ) -> Self {
51
+ match e {
52
+ Error :: A => ErrorObject :: owned (1 , " a" , None :: <()>),
53
+ Error :: B => ErrorObject :: owned (2 , " b" , None :: <()>),
54
+ }
55
+ }
56
+ }
57
+
58
+ #[rpc(server, client)]
59
+ pub trait Rpc {
60
+ // Use a custom error type that implements `Into<ErrorObject>`
61
+ #[method(name = " custom_err_ty" )]
62
+ async fn custom_err_type (& self ) -> Result <String , Error > {
63
+ Err (Error :: A )
64
+ }
65
+
66
+ // Use `ErrorObject` as error type directly.
67
+ #[method(name = " err_obj" )]
68
+ async fn error_obj (& self ) -> RpcResult <String > {
69
+ Err (ErrorObjectOwned :: owned (1 , " c" , None :: <()>))
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### [ Changed]
75
+ - remove ` CallError ` ([ #1087 ] ( https://github.com/paritytech/jsonrpsee/pull/1087 ) )
76
+
77
+ ### [ Fixed]
78
+ - fix(proc macros): support parsing params !Result ([ #1094 ] ( https://github.com/paritytech/jsonrpsee/pull/1094 ) )
79
+
7
80
## [ v0.17.1] - 2023-04-21
8
81
9
82
This release fixes HTTP graceful shutdown for the server.
0 commit comments