From 59aa895ec29ea8006a0e97b638331170068961f6 Mon Sep 17 00:00:00 2001 From: Dino Date: Mon, 5 Oct 2026 22:28:52 -0400 Subject: [PATCH] improve error message when secfile not found RM #2319 --- server/fcdb.c | 8 ++++++++ server/stdinhand.c | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/server/fcdb.c b/server/fcdb.c index a4b41a3abc..64a1822d39 100644 --- a/server/fcdb.c +++ b/server/fcdb.c @@ -122,9 +122,17 @@ static bool fcdb_load_config(const char *filename) { struct section_file *secfile; const char *val; + struct stat buf; fc_assert_ret_val(filename != nullptr, FALSE); + /* does file exist? */ + if (fc_stat(filename, &buf) != 0) { + log_error(_("Cannot load fcdb config file '%s':\n%s"), filename, + fc_strerror(fc_get_errno())); + return FALSE; + } + if (!(secfile = secfile_load(filename, FALSE))) { log_error(_("Cannot load fcdb config file '%s':\n%s"), filename, secfile_error()); diff --git a/server/stdinhand.c b/server/stdinhand.c index 8b20f354ad..bea45f8296 100644 --- a/server/stdinhand.c +++ b/server/stdinhand.c @@ -3851,8 +3851,21 @@ bool load_command(struct connection *caller, const char *filename, bool check, } } - /* Attempt to parse the file */ + { + struct stat buf; + + /* does file exist? */ + if (fc_stat(arg, &buf) != 0) { + log_error("Error loading savefile '%s': %s", arg, + fc_strerror(fc_get_errno())); + cmd_reply(CMD_LOAD, caller, C_FAIL, _("Could not load savefile: %s"), + arg); + dlsend_packet_game_load(game.est_connections, FALSE, arg); + return FALSE; + } + } + /* Attempt to parse the file */ if (!(file = secfile_load(arg, FALSE))) { log_error("Error loading savefile '%s': %s", arg, secfile_error()); cmd_reply(CMD_LOAD, caller, C_FAIL, _("Could not load savefile: %s"), -- 2.31.0