Ensure errors are correctly logged