Log errors correctly