mirror of https://github.com/rust-lang/book
Ch. 12.3: be clearer about how `expect` was used
This commit is contained in:
parent
15616bc09b
commit
54726034c5
|
@ -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
|
Right now, regardless of the situation, we’d print the same error message for
|
||||||
everything, which wouldn’t give the user any information!
|
everything, which wouldn’t give the user any information!
|
||||||
|
|
||||||
Fourth, if the user runs our program without specifying enough arguments,
|
Fourth, we use `expect` to handle an error, and if the user runs our program
|
||||||
they’ll get an `index out of bounds` error from Rust that doesn’t clearly
|
without specifying enough arguments, they’ll get an `index out of bounds` error
|
||||||
explain the problem. It would be best if all the error-handling code were
|
from Rust that doesn’t clearly explain the problem. It would be best if all the
|
||||||
in one place so future maintainers had only one place to consult the code
|
error-handling code were in one place so future maintainers had only one place
|
||||||
if the error-handling logic needed to change. Having all the error-handling
|
to consult the code if the error-handling logic needed to change. Having all the
|
||||||
code in one place will also ensure that we’re printing messages that
|
error-handling code in one place will also ensure that we’re printing messages
|
||||||
will be meaningful to our end users.
|
that will be meaningful to our end users.
|
||||||
|
|
||||||
Let’s address these four problems by refactoring our project.
|
Let’s address these four problems by refactoring our project.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue