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

Add errors example demo file #151

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Oct 22, 2023

Add an errors example that creates and prints various error types from the crate. This is useful for two main purposes:

  • Helps us catch mistakes by exercising error paths.
  • Helps us check that error output is useful for debugging.
  • Helps us check that output for "alloc" builds is good/useful (no-std)

Run with appropriate features to verify the output, e.g.,

      `cargo run --example errors --no-default-features --features=alloc`

This example is prone to go stale, is it useful? I could not think of any other way to verify that our error output was good (in both std and no-std environments).

Add an `errors` example that creates and prints various error types from
the crate. This is useful for two main purposes:

- Helps us catch mistakes by exercising error paths.
- Helps us check that error output is useful for debugging.
- Helps us check that output for "alloc" builds is good/useful (no-std)

Run with appropriate features to verify the output, e.g.,

  `cargo run --example errors --no-default-features --features=alloc`
@tcharding tcharding marked this pull request as ready for review October 30, 2023 20:31
@apoelstra
Copy link
Member

Hmm, concept ACK 61b6300.

I think in practice this'd be pretty hard to keep in sync with the actual error types. Maybe it should be a collection of unit tests rather than examples?

@tcharding
Copy link
Member Author

Its only about the "meaningfulness" of the error messages, I couldn't think of a way to test this except look at it every now and again. Once we are happy I don't think it will matter if some are missed, since devs will tend to copy the error style currently there.

@apoelstra
Copy link
Member

Ok, makes sense.

After running the example all the error messages look great to me except that we should drop code= on the InvalidChar message.

@tcharding
Copy link
Member Author

Sweet! Thanks for running them.

Remove the 'code=' and just write the character in single quotes.
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK a321ee5

@apoelstra
Copy link
Member

Do you want this to be merged?

@tcharding
Copy link
Member Author

Maybe just leave it here and I'll have a go doing it in another repo, then see if it feels like its worth having. I'm not 100% sure it won't just sit and rot never to be touched again.

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.

2 participants