Changing exceptions to LogErrors where appropriate

Forward-port of #5803