Added a bunch of tests for the new error handling

I've moved the error handling into the library. Also added automated
tests to prove the error handling yields expected results.

CCMAIL: apachelogger@ubuntu.com
Changing two lines from boilerplate.

I accidentally left some boilerplate in the two test files I added.

GIT_SILENT
Made changes per Harald's feedback, cleaning up error handling.

Cleaned up error handling, added four more error cases. Also updated
unit tests to account for the new error cases.

CCMAIL: sitter@kde.org
REVIEW: 115821