mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Added a templated derived exception to KeyNotFound so that you can figure out *which* key wasn't found.
This commit is contained in:
@@ -79,6 +79,20 @@ namespace YAML
|
||||
: RepresentationException(line_, column_, ErrorMsg::KEY_NOT_FOUND) {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class TypedKeyNotFound: public KeyNotFound {
|
||||
public:
|
||||
TypedKeyNotFound(int line_, int column_, const T& key_)
|
||||
: KeyNotFound(line_, column_), key(key_) {}
|
||||
|
||||
T key;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
TypedKeyNotFound <T> MakeTypedKeyNotFound(int line, int column, const T& key) {
|
||||
return TypedKeyNotFound <T> (line, column, key);
|
||||
}
|
||||
|
||||
class BadDereference: public RepresentationException {
|
||||
public:
|
||||
BadDereference()
|
||||
|
@@ -119,7 +119,7 @@ namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
throw KeyNotFound(m_line, m_column);
|
||||
throw MakeTypedKeyNotFound(m_line, m_column, key);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
Reference in New Issue
Block a user