Add filename to the BadFile exception (#858)

The BadFile exception which is thrown when failing to open a file now
contains the filename.
This commit is contained in:
Ted Lyngmo
2020-05-07 21:46:28 +02:00
committed by GitHub
parent 9fb5153487
commit a98b8af448
2 changed files with 10 additions and 9 deletions

View File

@@ -30,9 +30,9 @@ Node Load(std::istream& input) {
}
Node LoadFile(const std::string& filename) {
std::ifstream fin(filename.c_str());
std::ifstream fin(filename);
if (!fin) {
throw BadFile();
throw BadFile(filename);
}
return Load(fin);
}
@@ -63,9 +63,9 @@ std::vector<Node> LoadAll(std::istream& input) {
}
std::vector<Node> LoadAllFromFile(const std::string& filename) {
std::ifstream fin(filename.c_str());
std::ifstream fin(filename);
if (!fin) {
throw BadFile();
throw BadFile(filename);
}
return LoadAll(fin);
}