mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Set LoadFile and LoadAllFromFile to throw an exception if we can't load the file
This commit is contained in:
@@ -30,6 +30,8 @@ namespace YAML
|
||||
|
||||
Node LoadFile(const std::string& filename) {
|
||||
std::ifstream fin(filename.c_str());
|
||||
if(!fin)
|
||||
throw BadFile();
|
||||
return Load(fin);
|
||||
}
|
||||
|
||||
@@ -59,6 +61,8 @@ namespace YAML
|
||||
|
||||
std::vector<Node> LoadAllFromFile(const std::string& filename) {
|
||||
std::ifstream fin(filename.c_str());
|
||||
if(!fin)
|
||||
throw BadFile();
|
||||
return LoadAll(fin);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user