Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Better error message and avoiding enum forward declarations. #40

Merged
merged 1 commit into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions emitters/yaml_base_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions emitters/yaml_enum_emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const std::string&>(ns) + "::";
Expand Down