Skip to content

convert some unwrap() to expect(format!(...)) #4

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

durka
Copy link
Contributor

@durka durka commented Nov 7, 2015

unwrap() produces panics with no explanation, and on some platforms there are no line numbers in the backtrace even in debug builds (rust-lang/rust#24346). expect() with an informative message is a much better user experience.

I didn't convert all instances -- I assume Regex::new isn't going to fail since it is used with constants, so I left those. And in a lot of cases the relevant condition is checked -- for instance if x.contains_key(y) { do_something(x.get(y).unwrap()) } -- however, these patterns should ideally be refactored to use matchor other methods to avoid unwrapping.

@johannhof
Copy link
Contributor

👍 thanks

johannhof pushed a commit that referenced this pull request Nov 8, 2015
convert some unwrap() to expect(format!(...))
@johannhof johannhof merged commit 133da08 into cobalt-org: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.

2 participants