[runtime] Improve error checking for temporary file creation in the AOT compiler.