Skip to content
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

Export RuntimeError for RPC calls #426

Closed
gregdhill opened this issue Feb 2, 2022 · 3 comments · Fixed by #427
Closed

Export RuntimeError for RPC calls #426

gregdhill opened this issue Feb 2, 2022 · 3 comments · Fixed by #427

Comments

@gregdhill
Copy link
Contributor

This RPC returns Result<(), DispatchError> in the response body. I don't think it is currently possible to cast the generated DispatchError to RuntimeError because it is not exported.

@gregdhill
Copy link
Contributor Author

gregdhill commented Feb 2, 2022

Related: Deserialize is not implemented for DispatchError @jsdw do you know how to solve this?

@jsdw
Copy link
Collaborator

jsdw commented Feb 3, 2022

#427 Seems perfectly reasonable to me and would enable you to create an instance of the Error<E> type!

Merging that issue closed this; is that fair or would you prefer this stay open?

Hmm Deserialize not being implemented; that's a bit more tricky. At the mo, DispatchError is generated and given the same bounds as other generated types. You could try something like this:

#[subxt::subxt(
    runtime_metadata_path = "path/to/metadata.scale",
    generated_type_derives = "Deserialize"
)]

Which adds Deserialize to add types, but I somehow suspect it wouldn't work!

If you know the shape of your DispatchError, I suppose you could manually write a deserialize function or wrapping type to do so; it depends on what your aim is really?

@gregdhill
Copy link
Contributor Author

@jsdw please see my approach here, although it is not particularly elegant...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants