-
Notifications
You must be signed in to change notification settings - Fork 72
5.7. Error Handling (part 2) #93
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
5.7. Error Handling (part 2) #93
Conversation
<!-- or can we continue using combinators? --> | ||
もちろん現実のコードは、いつもこんなにクリーンではありません。 | ||
時には `Option` 型と `Result` 型が混在していることもあるでしょう。 | ||
そんな時は、明確なケース分析に頼るしかないのでしょうか? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このexplicitは他の部分と同様「明示的な」が良いとおもいます。
あと、"case analysis"の訳ですが、「場合分け」はいかがでしょうか?
数学などでの場合分けによる証明を "proof by case analysis" といったりします。
また、SICPでも"case analysis"は、「場合分け」と訳されているみたいです。(http://sicp.iijlab.net/fulltext/x116.html)
数点コメントさせていただきました。 |
ここでの変更点は、(エラーを文字列に変換する) `map_err(|e| e.to_string())` を、`map_err(CliError::Io)` や `map_err(CliError::Parse)` へ切り替えたことです。 | ||
こうして *呼び出し元* が、ユーザーに対してどの程度の詳細を報告するか決められるようになりました。 | ||
`String` をエラー型として用いることは、事実上、呼び出し元からこうした選択肢を奪ってしまいます。 | ||
`CliError` のような独自の `enum` エラー型を用いることは、 *構造化データ* によるエラーの説明だけでなく、これまでと同様の使いやすさをもたらします。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここの「構造化データ」も「構造化されたデータ」に統一したほうが良いように思います。
(前回まとめてコメントすべきでしたが、見落としていました。すみません)
修正確認しました! |
- Apply review comment - Fix a broken link
<!-- 3. A problem parsing the data as a number. --> | ||
1. ファイルを開くときの問題 | ||
2. ファイルからデータを読み込む時の問題 | ||
3. データを数値としてパースするときの問題 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
細かいですが、1と3と同様に、2も「ファイルからデータを読み込む「とき」の問題」だと思います
Apply review comment
@ykomatsu さん、レビューありがとうございました。 レビュー結果を反映したので、マージしようと思います。 |
5.7. Error Handling (part 2)
@KeenS さん
「5.7. エラーハンドリング」のパート2です。レビューをお願いします。(TranslationTable.mdの変更はありません)