Skip to content

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

Merged
merged 4 commits into from
Feb 20, 2016

Conversation

tatsuya6502
Copy link
Member

@KeenS さん

「5.7. エラーハンドリング」のパート2です。レビューをお願いします。(TranslationTable.mdの変更はありません)

<!-- or can we continue using combinators? -->
もちろん現実のコードは、いつもこんなにクリーンではありません。
時には `Option` 型と `Result` 型が混在していることもあるでしょう。
そんな時は、明確なケース分析に頼るしかないのでしょうか?
Copy link
Contributor

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)

@keiichiw
Copy link
Contributor

数点コメントさせていただきました。

@tatsuya6502
Copy link
Member Author

@kw-udon さん、

レビューありがとうございました!

"case analysis" は「場合分け」と訳すのが一般的なのですね。たしかに、これなら自然な日本語なのでいいですね。勉強になりました。"structured data" もご提案通り「構造化されたデータ」に統一しました。

その他、ご指摘の誤訳含め修正しました。(修正のコミット

ここでの変更点は、(エラーを文字列に変換する) `map_err(|e| e.to_string())` を、`map_err(CliError::Io)` や `map_err(CliError::Parse)` へ切り替えたことです。
こうして *呼び出し元* が、ユーザーに対してどの程度の詳細を報告するか決められるようになりました。
`String` をエラー型として用いることは、事実上、呼び出し元からこうした選択肢を奪ってしまいます。
`CliError` のような独自の `enum` エラー型を用いることは、 *構造化データ* によるエラーの説明だけでなく、これまでと同様の使いやすさをもたらします。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここの「構造化データ」も「構造化されたデータ」に統一したほうが良いように思います。
(前回まとめてコメントすべきでしたが、見落としていました。すみません)

@keiichiw
Copy link
Contributor

修正確認しました!
"structured data" が他にもう一箇所でてきていたことに気づいたので、そこだけコメントつけました。
よろしくお願いします。

- Apply review comment
- Fix a broken link
@tatsuya6502
Copy link
Member Author

@kw-udon さん、ありがとうございます。ご指摘の "structured data" の訳を修正しました。

あと、ページ内リンクが1箇所壊れていたので、直しました。

修正のコミット

<!-- 3. A problem parsing the data as a number. -->
1. ファイルを開くときの問題
2. ファイルからデータを読み込む時の問題
3. データを数値としてパースするときの問題
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

細かいですが、1と3と同様に、2も「ファイルからデータを読み込む「とき」の問題」だと思います

@tatsuya6502
Copy link
Member Author

@ykomatsu さん、レビューありがとうございました。

レビュー結果を反映したので、マージしようと思います。

tatsuya6502 added a commit that referenced this pull request Feb 20, 2016
@tatsuya6502 tatsuya6502 merged commit fa5b6ca into rust-lang-ja:master Feb 20, 2016
@tatsuya6502 tatsuya6502 modified the milestone: 1.6 Apr 28, 2016
@tatsuya6502 tatsuya6502 deleted the error-handling-part2 branch April 29, 2016 22:05
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.

3 participants