-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch from anyhow::Result to std Result #333
Conversation
tokio::spawn(async move { server.start().await }); | ||
addr | ||
Ok(addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
@@ -18,3 +18,7 @@ log = { version = "0.4", default-features = false } | |||
serde = { version = "1", default-features = false, features = ["derive"] } | |||
serde_json = { version = "1", default-features = false, features = ["alloc", "raw_value", "std"] } | |||
thiserror = "1.0" | |||
# TODO: a bit sad to have to pull in soketto to handle errors | |||
soketto = "0.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I don't know how handle those without removing the shared error type.
but maybe a good idea to kill the big error type and that each crates has to define their own error type in another PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't that make it tricky to share code between the servers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, unless you come up with super nice generic error type that both can use but then you need some extra boiler-plate.
Like map.err(|e| Error::Transport(Box::new(e))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of a better way other than adding features, which I'm not sure is such a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, you mean making soketto
and hyper
optional dependencies?
That's ok but why not let each crate implement implement the From<TransportError> for Error
?
Then we shouldn't bring in any extra dependencies but a little bit of "redundant code", like for client/server as long they use the same transport library
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hat's ok but why not let each crate implement implement the
From<TransportError> for Error
?
Then we shouldn't bring in any extra dependencies but a little bit of "redundant code", like for client/server as long they use the same transport library
@@ -130,7 +130,8 @@ impl RpcModule { | |||
self.methods.insert( | |||
unsubscribe_method_name, | |||
Box::new(move |id, params, tx, conn| { | |||
let sub_id = params.one().map_err(|e| anyhow::anyhow!("{:?}", e))?; | |||
// let sub_id = params.one().map_err(|e| anyhow::anyhow!("{:?}", e))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// let sub_id = params.one().map_err(|e| anyhow::anyhow!("{:?}", e))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. Fixed this one in #334
Don't return
anyhow::Result
and instead just usethiserror
and standardResult<T, Error>
whereError
is thejsonrpsee_types::error::Error
type.The downside is that with this PR
jsonrpsee_types
depends on bothsoketto
andhyper
. I think makingjsonrpsee_types
as dependency-free as possible was a big part of an external crate in the first place. OTOH all users will depend on at least one of them.