C++ error message output format
- by sub
If I want to trigger an error in my interpreter I call this function:
Error( ErrorType type, ErrorSeverity severity, const char* msg, int line );
However, with that I can only output
Name error: Undefined variable in line 1
instead of
Name error: Undefined variable 'someVariableName' in line 1
I'm working entirely with strings (except for the error messages as they all are constant at the moment), so sprintf won't work.
What is the best way to create an efficient error function that can output a constant message combined with a string that describes which object, e.g.: a non-existing variable, triggered the error?