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 "Avoid discarding errors during error conversions" example #368

Merged
merged 1 commit into from Nov 18, 2017

Conversation

Projects
None yet
2 participants
@ludwigpacifici
Copy link
Contributor

ludwigpacifici commented Nov 15, 2017

fixes #215

@ludwigpacifici ludwigpacifici force-pushed the ludwigpacifici:master branch from 22c417c to 5df7c0b Nov 15, 2017

@ludwigpacifici

This comment has been minimized.

Copy link
Contributor Author

ludwigpacifici commented Nov 16, 2017

Hello @budziq

To me, the use case (get a random number via HTTP) is not very useful, but it shows the error handling with a relatively short code and covers what was discussed in #215.

If you have some ideas to improve it, let me know.

@budziq
Copy link
Collaborator

budziq left a comment

@ludwigpacifici some super minor suggestions below.

service will be queried via [reqwest] and then the response will be
parsed. Errors can be generated by the Rust standard library,
[reqwest] and by the web service. [`foreign_links`] are used for well
defined Rust errors. The `errors` macro is used to create an

This comment has been minimized.

@budziq

budziq Nov 16, 2017

Collaborator

errors is actually not a macro but a clause inside a error_chain! macro

This comment has been minimized.

@ludwigpacifici

ludwigpacifici Nov 16, 2017

Author Contributor

Thanks for the clarification! I did not know that. Is it called a DSL?

This comment has been minimized.

@budziq

budziq Nov 17, 2017

Collaborator

Is it called a DSL?

Yep, the error-chain crate defines a DSL via its macros.

fn main() {
if let Err(error) = run() {
match *error.kind() {
ErrorKind::Io(_) => println!("{:?}", error),

This comment has been minimized.

@budziq

budziq Nov 16, 2017

Collaborator

We might want to differentiate the println!s here a little. 1-2 word preamble should be enough

@ludwigpacifici ludwigpacifici force-pushed the ludwigpacifici:master branch from 5df7c0b to 3f84f37 Nov 17, 2017

@ludwigpacifici

This comment has been minimized.

Copy link
Contributor Author

ludwigpacifici commented Nov 17, 2017

Thanks for the comments. I updated the PR.

@budziq budziq merged commit ba94df6 into rust-lang-nursery:master Nov 18, 2017

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@budziq

This comment has been minimized.

Copy link
Collaborator

budziq commented Nov 18, 2017

Nicely done!

@ludwigpacifici

This comment has been minimized.

Copy link
Contributor Author

ludwigpacifici commented Nov 18, 2017

Thank you @budziq !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.