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

Improve error handling + consistency when no_std #13

Merged
merged 3 commits into from
Jul 31, 2023
Merged

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented Jul 28, 2023

I standardised no_std errors to be Display + Debug, which is closer to the "real" std::error::Error trait (and is what serde does too for no_std), exposed a couple of helpers to make constructing them from strings simpler (scale-value and subxt use these) and made use of derive_more since it's used in scale-value anyway, and is rather helpful.

Also bumped the version ready for a new release once this merges.

Part of a series:

Changes tested against Subxt; I'll update that next.

WrongLength {
/// Length we have
actual_len: usize,
/// Length expected for type.
expected_len: usize,
},
/// We cannot encode the number given into the target type; it's out of range.
#[display(fmt = "Number {value} is out of range for target type {expected}")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: we could keep consistency with commit, although I like it how it is right now

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I undid the other ones because I realised they weren't really necessary!

@jsdw jsdw merged commit 2697f92 into main Jul 31, 2023
@jsdw jsdw deleted the jsdw-error-handling branch July 31, 2023 09:21
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 this pull request may close these issues.

3 participants