Bug #2319
openimprove error message when secfile not found
0%
Description
From server prompt, enter "load foo.sav" where "foo.sav" file does not exist. Get error message -
1: Error loading savefile '33c2c3.sav': In secfile_lookup_str_vec() [../utility/registry_ini.c:2531]: secfile '/Applications/Freeciv.app/Contents/share/freeciv/civ2civ3/game.ruleset' in section 'nullptr': "goods_good.helptext" entry doesn't exist.
The part -
...civ2civ3/game.ruleset' in section 'nullptr': "goods_good.helptext" entry doesn't exist.
is bogus. What's happening is that secfile_load() returns NULL if the file is not found, as well as when there's a secfile parse error. The calling routine tests secfile_load() return value and if it's null, calls "log_debug("Error reading '%s':\n%s", ... secfile_error());" and secfile_error() returns the most recent leftover secfile parse error, which is irrelevant when the file is not found. So some calls to secfile_load() should be preceded by calls to fc_stat() to give better error messages.
Files
Updated by Dean Brown 13 days ago
- File 2319_Main_Part1.patch added
- File 2319_Part2.patch added
- File 2319_S3_3_Part1.patch added
Looking for other instances, in most other cases the file's existence has already been tested before the call to secfile_load(). In addition to the call in stdinhand.c routine load_command(), there's one in fcdb.c routine fcdb_load_config() to be fixed. I'm unclear about the one in gamehand.c routine handle_single_want_hack_req() - a fc_stat() test here may be redundant, so I put that in a separate patch.
Updated by Marko Lindqvist 9 days ago
Main patch conflicts with #2323 - please rebase on top of that.
Updated by Marko Lindqvist 9 days ago
Maybe you should use fc_strerror(fc_get_errno()) instead of blindly claiming that the error is "file not found"
Updated by Dean Brown 9 days ago
- File 2319_Main_Part1.patch 2319_Main_Part1.patch added
- File 2319_Part2.patch 2319_Part2.patch added
- File 2319_S3_3_Part1.patch 2319_S3_3_Part1.patch added
Thanks for the tip about fc_strerror(fc_get_errno())
Updated by Marko Lindqvist 9 days ago
- Tracker changed from Feature to Bug
Considering the wrong error message a bug.
Updated by Marko Lindqvist 8 days ago
- Status changed from New to In Review
- Assignee set to Marko Lindqvist
- Target version set to 3.2.7
Updated by Marko Lindqvist 8 days ago
- Blocks Feature #2340: fc_stat(): Accept nullptr buffer added
Updated by Marko Lindqvist 8 days ago
- Blocked by Feature #2323: fcdb.c : NULL -> nullptr added