From 750ef431189e047781da9365e2a3b13baa2ad073 Mon Sep 17 00:00:00 2001 From: Foster Brereton Date: Mon, 20 May 2019 11:50:07 -0700 Subject: [PATCH] better error message and avoiding enum forward declarations. --- emitters/yaml_base_emitter.cpp | 10 ++++++++-- emitters/yaml_enum_emitter.cpp | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/emitters/yaml_base_emitter.cpp b/emitters/yaml_base_emitter.cpp index 9f33cd0..cf2d7e2 100644 --- a/emitters/yaml_base_emitter.cpp +++ b/emitters/yaml_base_emitter.cpp @@ -339,14 +339,20 @@ bool yaml_base_emitter::check_object_array(const std::string& filepath, check_notify(filepath, nodepath, key, validate_message, update_message); }; + const auto notify_fail = [&](const std::string& message) { + check_notify(filepath, nodepath, key, message, message); + }; + if (!expected_node.count(key)) { - throw std::runtime_error("missing expected array?"); + notify_fail("missing expected array"); + throw std::runtime_error("Merge object array failure"); } const json& expected = expected_node[key]; if (!expected.is_array()) { - throw std::runtime_error("expected type mismatch?"); + notify_fail("expected type mismatch"); + throw std::runtime_error("Merge object array failure"); } json& result = merged_node[key]; diff --git a/emitters/yaml_enum_emitter.cpp b/emitters/yaml_enum_emitter.cpp index 93c2d34..10e6b23 100644 --- a/emitters/yaml_enum_emitter.cpp +++ b/emitters/yaml_enum_emitter.cpp @@ -45,6 +45,9 @@ bool yaml_enum_emitter::do_merge(const std::string& filepath, bool yaml_enum_emitter::emit(const json& j) { const std::string& name = j["name"]; + // Most likely an enum forward declaration. Nothing to document here. + if (j["values"].empty()) return true; + std::string filename; for (const auto& ns : j["namespaces"]) { filename += static_cast(ns) + "::";