write out cache file when raising a build error exception