Skip to content

doc: error-handling.md: main case analysis for search #29686

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

Merged
merged 1 commit into from
Nov 8, 2015

Conversation

jrburke
Copy link
Contributor

@jrburke jrburke commented Nov 8, 2015

In src/doc/trpl/error-handling.md, in this section:

Error handling with Box

It mentions three steps, to "convert this to proper error handling", the last one being:

  1. Handle the error in main.

However, it is not shown. This pull request adds a code example showing how main's call to search should use case analysis. I am still very much new to learning Rust, so this may not be idiomatic. Happy to make changes with guidance.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@Manishearth
Copy link
Member

r? @BurntSushi

println!("{}, {}: {:?}", pop.city, pop.country, pop.count);
}
}
Err(err) => panic!("{}", err)
Copy link
Member

Choose a reason for hiding this comment

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

Can you change this to println!("{}", err)? I don't think there's any reason to panic here, which would present an ugly error message to the user.

@BurntSushi
Copy link
Member

@jrburke Looks good, thank you! I had one small nit, but otherwise this looks good to go.

@jrburke jrburke force-pushed the docs-error-handling-search-case branch from 0ebf9ac to 0dd2c1c Compare November 8, 2015 17:53
@jrburke
Copy link
Contributor Author

jrburke commented Nov 8, 2015

@BurntSushi I changed panic to println, then I rebased and squashed over latest master. I thought I read somewhere about keeping commits separate during review, but cannot find that now, and was unsure if squashing to one commit after review for bot merging was preferred.

@Manishearth
Copy link
Member

@bors r=BurntSushi rollup

Thanks!

@bors
Copy link
Collaborator

bors commented Nov 8, 2015

📌 Commit 0dd2c1c has been approved by BurntSushi

@bors
Copy link
Collaborator

bors commented Nov 8, 2015

⌛ Testing commit 0dd2c1c with merge 9eb099d...

bors added a commit that referenced this pull request Nov 8, 2015
…ntSushi

In src/doc/trpl/error-handling.md, in this section:

It mentions three steps, to "convert this to proper error handling", the last one being:

3. Handle the error in main.

However, it is not shown. This pull request adds a code example showing how `main`'s call to `search` should use case analysis. I am still very much new to learning Rust, so this may not be idiomatic. Happy to make changes with guidance.
@bors bors merged commit 0dd2c1c into rust-lang:master Nov 8, 2015
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.

6 participants