Skip to content

Commit db6deed

Browse files
authored
Include name of anchor in invalid anchor error (#1015)
1 parent 79aa6d5 commit db6deed

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/yaml-cpp/exceptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const char* const ZERO_INDENT_IN_BLOCK =
6565
const char* const CHAR_IN_BLOCK = "unexpected character in block scalar";
6666
const char* const AMBIGUOUS_ANCHOR =
6767
"cannot assign the same alias to multiple nodes";
68-
const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined";
68+
const char* const UNKNOWN_ANCHOR = "the referenced anchor is not defined: ";
6969

7070
const char* const INVALID_NODE =
7171
"invalid node; this may result from using a map iterator as a sequence "

src/singledocparser.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,11 @@ anchor_t SingleDocParser::RegisterAnchor(const std::string& name) {
424424
anchor_t SingleDocParser::LookupAnchor(const Mark& mark,
425425
const std::string& name) const {
426426
auto it = m_anchors.find(name);
427-
if (it == m_anchors.end())
428-
throw ParserException(mark, ErrorMsg::UNKNOWN_ANCHOR);
427+
if (it == m_anchors.end()) {
428+
std::stringstream ss;
429+
ss << ErrorMsg::UNKNOWN_ANCHOR << name;
430+
throw ParserException(mark, ss.str());
431+
}
429432

430433
return it->second;
431434
}

0 commit comments

Comments
 (0)