Add logging and fix exception messages