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

ch12-03: expect is not used multitude times by this chapter #3287

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/ch12-03-improving-error-handling-and-modularity.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ example, the file could be missing, or we might not have permission to open it.
Right now, regardless of the situation, we’d print the same error message for
everything, which wouldn’t give the user any information!

Fourth, we use `expect` repeatedly to handle different errors, and if the user
runs our program without specifying enough arguments, they’ll get an `index out
of bounds` error from Rust that doesn’t clearly explain the problem. It would
be best if all the error-handling code were in one place so future maintainers
had only one place to consult the code if the error-handling logic needed to
change. Having all the error-handling code in one place will also ensure that
we’re printing messages that will be meaningful to our end users.
Fourth, if the user runs our program without specifying enough arguments,
they’ll get an `index out of bounds` error from Rust that doesn’t clearly
explain the problem. It would be best if all the error-handling code were
in one place so future maintainers had only one place to consult the code
if the error-handling logic needed to change. Having all the error-handling
code in one place will also ensure that we’re printing messages that
will be meaningful to our end users.
chriskrycho marked this conversation as resolved.
Show resolved Hide resolved

Let’s address these four problems by refactoring our project.

Expand Down