Added proper error logging and exiting.

No exeption is thrown. I don't think we need that.