From 0526d7c29997bbb02400e4b23b23e1ce6595e040 Mon Sep 17 00:00:00 2001 From: Jonathan Hamilton Date: Thu, 28 May 2015 20:10:25 -0700 Subject: [PATCH] Return fallback if .as(fallback) called on a node that doesn't exist Since 1025f76df1b32b6ec3571ca928d7797a768a3341 it seems that missing nodes point to a 'zombie' node, where the m_isValid member is false. This caused .as(const S& fallback) throw an exception if the node was missing, instead of returning the provided fallback value (as was the behaviour previous to the above commit) --- include/yaml-cpp/node/impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h index 26cccbd..d711527 100644 --- a/include/yaml-cpp/node/impl.h +++ b/include/yaml-cpp/node/impl.h @@ -149,7 +149,7 @@ inline const T Node::as() const { template inline const T Node::as(const S& fallback) const { if (!m_isValid) - throw InvalidNode(); + return fallback; return as_if(*this)(fallback); }