Skip to content

Commit

Permalink
Don't catch config::error in config_cache::read_configs()
Browse files Browse the repository at this point in the history
Reverts a bit of commit d6dfec6 to fix
a regression affecting both master and 1.12 since after version 1.11.14
which was causing WML validity errors to not abort the WML load process
or result in a message to the user in the GUI.

The WML parser and preprocessor throw config::error and
preproc_config::error to signal callers of issues with user input (WML
documents, in this case).

We need any exceptions thrown by the WML parser or preprocessor to
propagate upstream so they can be caught by the code responsible for
initiating the sequence so it can best decide how to present them to the
user. For example, the game_config_manager class will format and pass
them to gui2::twml_error so that the user can be informed of errors in
an add-on or mainline through the GUI.

Because config_cache::read_configs() was catching the exception and not
propagating it upstream due to a change that's part of the
aforementioned commit, this sequence was broken, and while the error was
reported to stderr, the game continued as normal in most cases with
a malformed half-parsed WML tree, resulting in all kinds of misbehavior.

This issue was originally reported in the forums by SkyOne:
<http://r.wesnoth.org/p571380>
  • Loading branch information
irydacea committed Jun 8, 2014
1 parent 57cc44b commit f7c34df
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/config_cache.cpp
Expand Up @@ -146,13 +146,9 @@ namespace game_config {

void config_cache::read_configs(const std::string& path, config& cfg, preproc_map& defines_map)
{
try {
//read the file and then write to the cache
scoped_istream stream = preprocess_file(path, &defines_map);
read(cfg, *stream);
} catch (config::error & e) {
ERR_CACHE << "error parsing configs in '" << path << "', got config::error\n" << e.message << std::endl;
}
//read the file and then write to the cache
scoped_istream stream = preprocess_file(path, &defines_map);
read(cfg, *stream);
}

void config_cache::read_cache(const std::string& path, config& cfg)
Expand Down

0 comments on commit f7c34df

Please sign in to comment.