tools: improve error handling in node_mksnapshot · nodejs/node@6696d1d

Original file line numberDiff line numberDiff line change

@@ -66,8 +66,16 @@ int BuildSnapshot(int argc, char* argv[]) {

6666

std::vector<std::string>(argv, argv + argc),

6767

node::ProcessInitializationFlags::kGeneratePredictableSnapshot);

6868
69+

if (result->exit_code() != 0) {

70+

for (const std::string& error : result->errors()) {

71+

std::cerr << error << "\n";

72+

}

73+

std::cerr << "node_mksnapshot failed with exit code " << result->exit_code()

74+

<< "\n";

75+

return static_cast<int>(result->exit_code());

76+

}

77+
6978

CHECK(!result->early_return());

70-

CHECK_EQ(result->exit_code(), 0);

7179
7280

std::string out_path;

7381

std::optional<std::string_view> builder_script_path = std::nullopt;