From 3de39c70c11c4b50d231799ba27289872832df1a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer <akohlmey@gmail.com> Date: Tue, 16 Jan 2018 11:29:48 -0500 Subject: [PATCH] print variable name with errors only for known variables. this makes errors for "anonymous" evaluations (if statement, immediate variables) less confusing. --- src/variable.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/variable.cpp b/src/variable.cpp index 2991f8c78a..d77bc0e696 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -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 -- GitLab