Ch. 12.3: be clearer about how `expect` was used

This commit is contained in:
Chris Krycho 2024-04-19 13:35:31 -06:00 committed by GitHub
parent 15616bc09b
commit 54726034c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 7 deletions

View File

@ -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, wed print the same error message for
everything, which wouldnt give the user any information!
Fourth, if the user runs our program without specifying enough arguments,
theyll get an `index out of bounds` error from Rust that doesnt 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 were printing messages that
will be meaningful to our end users.
Fourth, we use `expect` to handle an error, and if the user runs our program
without specifying enough arguments, theyll get an `index out of bounds` error
from Rust that doesnt 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 were printing messages
that will be meaningful to our end users.
Lets address these four problems by refactoring our project.