puppetlabs/puppetdb — pull request #1139 by LaMetterey (2014-10-30 23:22:51+00:00)
Title: (PDB-168) Improve error messages from .ini file parsing.

Pushing this as conversation fodder, even though I already have planned changes in the works. One major question is whether we should make these changes inside trapperkeeper, instead of within puppetdb. Seems like we should, so all users of TK can benefit, but ... objections?

Other items to stipulate:
- Note that this checkin uses Exceptions as a sort of callback mechanism. Ryan showed me how we can use atoms to accomplish what I want more cleanly. I'll modify and re-pull when I get some time.
- Also planning to only check for IOException, and not FileNotFound as well, since IOE is the super. Lastly, I'll be learning how to use the test-utils to scrape and verify log output.

Changes in this PR:
- Split hook-tk-parse-config-data and put the bulk into hook-tk-parse-config-data'
so I could pass in an action-on-error-fn. In production this will be a System/exit
call, but test code uses it as a sort of callback mechanism to validate exception
handling.
- Added code to handle 3 potential exceptions thrown by TK parse-config-data. The
full exception is logged, a clean+simple error is reported to the console, and the
production system will exit immediately.
- Added test code to induce each exception condition, and verify expected handling.
- Validated expected production and test behavior with missing/empty/invalid
configuration files, using 'lein run services -c config.ini' and
'lein test puppetlabs.puppetdb.config-test' commands.