Get rid of RET_SYS, just use RET_FAIL

RET_SYS was used for commands failing due to internal or environmental
errors, but not really systematically.  The difference to RET_FAIL is
how dispatch() treats them: RET_SYS got logged, and cost no BTUs.

More specific logging is possible at the point of failure than in
dispatch().  Make sure that's done for all failures that used to
return RET_SYS.

The change in BTU charging affects commands consider, offer, repay,
trade failing due to internal errors.  It also affects deity commands
reload and turn (irrelevant because deities get unlimited BTUs), and
commands apropos, info and motd (irrelevant because they cost no
BTUs).
This commit is contained in:
Markus Armbruster 2008-08-03 11:34:00 -04:00
parent e803950463
commit 29aefc356f
10 changed files with 42 additions and 36 deletions

View file

@ -99,7 +99,7 @@ info(void)
if (info_dp == 0) {
pr("Can't open info dir\n");
logerror("Can't open info dir \"%s\"\n", infodir);
return RET_SYS;
return RET_FAIL;
}
while ((dp = readdir(info_dp)) != 0) {
@ -146,13 +146,13 @@ info(void)
logerror("Cannot fstat for \"%s\" info file (%s)",
filename, strerror(errno));
fclose(fp);
return RET_SYS;
return RET_FAIL;
}
if ((statb.st_mode & S_IFREG) == 0) {
pr("Error reading info file for %s\n", name);
logerror("The info file \"%s\" is not regular file\n", filename);
fclose(fp);
return RET_SYS;
return RET_FAIL;
}
pr("Information on: %s Last modification date: %s",
name, ctime(&statb.st_mtime));
@ -193,7 +193,7 @@ apro(void)
if (info_dp == NULL) {
pr("Can't open info dir \n");
logerror("Can't open info dir \"%s\"", infodir);
return RET_SYS;
return RET_FAIL;
}
fbuf = malloc(256);
@ -315,7 +315,6 @@ info(void)
switch (GetLastError()) {
case ERROR_FILE_NOT_FOUND:
pr("Sorry, there is no info on %s\n", name);
return RET_FAIL;
break;
case ERROR_PATH_NOT_FOUND:
pr("Can't open info dir\n");
@ -326,7 +325,7 @@ info(void)
logerror("Error (%lu) reading info dir(%s)\\file(%s)",
GetLastError(), infodir, filename);
}
return RET_SYS;
return RET_FAIL;
}
do {
if ((fData.dwFileAttributes != (DWORD)-1) &&
@ -381,7 +380,7 @@ info(void)
logerror("The info file \"%s\" is not regular file\n",
filename);
fclose(fp);
return RET_SYS;
return RET_FAIL;
}
}
@ -429,7 +428,7 @@ apro(void)
logerror("Error (%lu) reading info dir(%s)\\file(%s)",
GetLastError(), infodir, filename);
}
return RET_SYS;
return RET_FAIL;
}
fbuf = malloc(256);