print variable name with errors only for known variables.

this makes errors for "anonymous" evaluations (if statement, immediate variables) less confusing.
This commit is contained in:
Axel Kohlmeyer
2018-01-16 11:29:48 -05:00
parent f37f4f0041
commit 3de39c70c1

View File

@ -4589,18 +4589,19 @@ char *Variable::find_next_comma(char *str)
/* ----------------------------------------------------------------------
debug routine for printing formula tree recursively
helper routine for printing variable name with error message
------------------------------------------------------------------------- */
void Variable::print_var_error(const char *srcfile, int lineno,
const char *errmsg, int ivar)
{
const char *varname = (const char*)"(unknown)";
if ((ivar >= 0) && (ivar < nvar)) varname = names[ivar];
if ((ivar >= 0) && (ivar < nvar)) {
char msg[128];
char msg[128];
sprintf(msg,"Variable %s: %s",varname,errmsg);
error->all(srcfile,lineno,msg);}
sprintf(msg,"Variable %s: %s",names[ivar],errmsg);
error->all(srcfile,lineno,msg);
} else error->all(srcfile,lineno,errmsg);
}
/* ----------------------------------------------------------------------
debug routine for printing formula tree recursively