Fix bugs for on build with legacy error reporting