From 5ff18a9b27c1f79ad6385371684fd35c4f930bb7 Mon Sep 17 00:00:00 2001 From: Angela Chen Date: Fri, 11 Aug 2023 01:54:43 -0400 Subject: [PATCH] Add error for invalid config file name --- src/ppx/command_line_parser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ppx/command_line_parser.cpp b/src/ppx/command_line_parser.cpp index 8e68ed039..9e768951f 100644 --- a/src/ppx/command_line_parser.cpp +++ b/src/ppx/command_line_parser.cpp @@ -151,7 +151,10 @@ std::optional CommandLineParser::Parse(int argc std::vector configJsonPaths; configJsonPaths = mOpts.GetOptionValueOrDefault("config-json-path", configJsonPaths); for (const auto& jsonPath : configJsonPaths) { - std::ifstream f(jsonPath); + std::ifstream f(jsonPath); + if (f.fail()) { + return "Invalid --config-json-path: " + jsonPath; + } nlohmann::json data = nlohmann::json::parse(f); if (auto error = AddJsonOptions(data)) { return error;