Skip to content

Commit

Permalink
Catch config::error exception which could be thrown by parser.
Browse files Browse the repository at this point in the history
I'm not sure if this is necessary as it is not reported, but
worst case is that not doing this could cause malformed
scenario files in the editor folder to crash wesnoth while
browsing in mp_create.
  • Loading branch information
cbeck88 committed May 23, 2014
1 parent f70cd0d commit 688747e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/multiplayer_create_engine.cpp
Expand Up @@ -824,7 +824,13 @@ void create_engine::init_all_levels()
for(size_t i = 0; i < user_scenario_names_.size(); i++)
{
config data;
read(data, *(preprocess_file(get_user_data_dir() + "/editor/scenarios/" + user_scenario_names_[i])));
try {
read(data, *(preprocess_file(get_user_data_dir() + "/editor/scenarios/" + user_scenario_names_[i])));
} catch (config::error & e) {
ERR_CF << "Caught a config error while parsing user made (editor) scenarios:\n" << e.message << std::endl;
ERR_CF << "Skipping file: " << (get_user_data_dir() + "/editor/scenarios/" + user_scenario_names_[i]) << std::endl;
continue;
}

scenario_ptr new_scenario(new scenario(data));
if (new_scenario->id().empty()) continue;
Expand Down

0 comments on commit 688747e

Please sign in to comment.