Write error message to stderr. Terminate process with specified code on failure.
Merge pull request #1 from ifaced/patch-1

Error handling