if a command throws an error, make sure we log correctly and then exit