@@ -23,6 +23,10 @@ toml::value read_data_from_toml(const ghc::filesystem::path file_path){
23
23
throw toml_error (" File '" + file_path.string () +
24
24
" ' could not be opened as it does not exist" );
25
25
}
26
+ if (ghc::filesystem::is_empty (file_path)) {
27
+ throw toml_error (" File '" + file_path.string () +
28
+ " ' appears to be empty" );
29
+ }
26
30
27
31
auto toml_data_ = toml::parse (file_path.string ());
28
32
return toml_data_;
@@ -95,6 +99,10 @@ std::string get_first_component(const ghc::filesystem::path &file_path){
95
99
throw toml_error (" File '" + file_path.string () +
96
100
" ' could not be opened as it does not exist" );
97
101
}
102
+ if (ghc::filesystem::is_empty (file_path)) {
103
+ throw toml_error (" File '" + file_path.string () +
104
+ " ' appears to be empty" );
105
+ }
98
106
const auto toml_data_ = toml::parse (file_path.string ());
99
107
100
108
return toml_data_.as_table ().begin ()->first ;
@@ -105,6 +113,10 @@ bool component_exists(const ghc::filesystem::path &file_path, const std::string
105
113
{
106
114
return false ;
107
115
}
116
+ if (ghc::filesystem::is_empty (file_path)) {
117
+ throw toml_error (" File '" + file_path.string () +
118
+ " ' appears to be empty" );
119
+ }
108
120
const auto toml_data_ = toml::parse (file_path.string ());
109
121
if (!toml_data_.contains (component)){
110
122
return false ;
@@ -115,4 +127,5 @@ bool component_exists(const ghc::filesystem::path &file_path, const std::string
115
127
}
116
128
117
129
}
130
+
118
131
}; // namespace FairDataPipeline
0 commit comments