Remove cache if build fails

Check for and log an error here, too. Just for completeness.