YS-L / csvlens

Command line csv viewer
MIT License
2.47k stars 41 forks source link

Lower level causes should be printed on error #45

Closed sgryjp closed 7 months ago

sgryjp commented 7 months ago

Would you consider to let csvlens print lower level causes on exiting with an error?

As of v0.5.0, csvlens does not print lower level causes stored in an anyhow::Error instance on error exit. This means that the error message is not very helpful as the root cause is not reported to users. For example, trying to open a non-existent file and trying to open an existing but not UTF-8 encoded file emits completely same message:

$ echo "亜" | iconv -f utf-8 -t cp932 > cp932.csv
$ csvlens cp932.csv
Failed to open file: cp932.csv
$ csvlens no-such-file.csv
Failed to open file: no-such-file.csv

Since an anyhow::Error instance contains lower level causes and provides some ways to extract them, using one of them should solve the situation.

YS-L commented 7 months ago

Hi @sgryjp, yes that makes a lot of sense. Thanks for the suggestion!