mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-23 10:50:58 +00:00
[cexpr] Add optional error message prefix string
The prefix gives more context to the error messages, making the system a lot easier to use (it was especially helpful when getting my cvar revamp into shape).
This commit is contained in:
parent
d68db74049
commit
021ec4962b
2 changed files with 12 additions and 2 deletions
|
@ -99,6 +99,7 @@ typedef struct exprctx_s {
|
|||
exprval_t *result;
|
||||
exprtab_t *symtab; // directly accessible symbols
|
||||
exprtab_t *external_variables; // accessible via $id
|
||||
const char *msg_prefix; // optional prefix for error messages
|
||||
struct memsuper_s *memsuper;
|
||||
const struct plitem_s *item;
|
||||
struct plitem_s *messages;
|
||||
|
|
|
@ -94,9 +94,18 @@ cexpr_error(exprctx_t *ctx, const char *fmt, ...)
|
|||
va_end (args);
|
||||
|
||||
if (ctx->messages) {
|
||||
PL_Message (ctx->messages, ctx->item, "%s", string->str);
|
||||
if (ctx->msg_prefix) {
|
||||
PL_Message (ctx->messages, ctx->item, "%s:%s",
|
||||
ctx->msg_prefix, string->str);
|
||||
} else {
|
||||
PL_Message (ctx->messages, ctx->item, "%s", string->str);
|
||||
}
|
||||
} else {
|
||||
Sys_Printf ("%s\n", string->str);
|
||||
if (ctx->msg_prefix) {
|
||||
Sys_Printf ("%s:%s\n", ctx->msg_prefix, string->str);
|
||||
} else {
|
||||
Sys_Printf ("%s\n", string->str);
|
||||
}
|
||||
}
|
||||
dstring_delete (string);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue