Skip to content

Commit 84baf6f

Browse files
committed
src: use graceful errors after schema validation
1 parent ef508a1 commit 84baf6f

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/node_config_file.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,13 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
255255

256256
simdjson::ondemand::parser json_parser;
257257
simdjson::ondemand::document document;
258-
CHECK_EQ(json_parser.iterate(file_content).get(document), simdjson::SUCCESS);
258+
if (json_parser.iterate(file_content).get(document)) {
259+
return ParseResult::InvalidContent;
260+
}
259261
simdjson::ondemand::object main_object;
260-
CHECK_EQ(document.get_object().get(main_object), simdjson::SUCCESS);
262+
if (document.get_object().get(main_object)) {
263+
return ParseResult::InvalidContent;
264+
}
261265

262266
// Get all available namespaces for validation
263267
std::vector<std::string> available_namespaces =
@@ -309,8 +313,9 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
309313
}
310314

311315
simdjson::ondemand::object namespace_object;
312-
CHECK_EQ(field.value().get_object().get(namespace_object),
313-
simdjson::SUCCESS);
316+
if (field.value().get_object().get(namespace_object)) {
317+
return ParseResult::InvalidContent;
318+
}
314319

315320
// Process options for this namespace using the unified method
316321
ParseResult result =

0 commit comments

Comments
 (0)