Fix an issue with schema validator not reporting errors at top level

This commit is contained in:
Celtic Minstrel 2022-12-28 16:07:16 -05:00
parent f43c52cdbf
commit 5ec1d80bc1
2 changed files with 13 additions and 3 deletions

View file

@ -282,12 +282,15 @@ void schema_validator::close_tag()
{
stack_.pop();
counter_.pop();
// cache_ is cleared in another place.
// cache_ is normally cleared in another place.
// However, if we're closing the root tag, clear it now
if(stack_.empty()) {
print_cache();
}
}
void schema_validator::validate(const config& cfg, const std::string& name, int start_line, const std::string& file)
void schema_validator::print_cache()
{
// close previous errors and print them to output.
for(auto& m : cache_.top()) {
for(auto& list : m.second) {
print(list);
@ -295,6 +298,12 @@ void schema_validator::validate(const config& cfg, const std::string& name, int
}
cache_.pop();
}
void schema_validator::validate(const config& cfg, const std::string& name, int start_line, const std::string& file)
{
// close previous errors and print them to output.
print_cache();
// clear cache
auto cache_it = cache_.top().find(&cfg);

View file

@ -118,6 +118,7 @@ protected:
virtual void print(message_info&);
private:
void print_cache();
typedef std::deque<message_info> message_list;
typedef std::map<const config*, message_list> message_map;