Added error logging for exceptions

PR then please.