Hello all,
Does anyone know how to output custom error messages? By this I mean
either or both of:
a) inserting my own strings into the "_______"s listed in error files.
So, while "confirm variable foo" produces "variable foo not found;
r(111)", I want to be able to have a command throw an error 111 with a
message like "index variable not found". If I -error 111-, it always
displays "invalid syntax", which is not very helpful. Often errors I
want to throw are related to error codes Stata has, but are slightly
different, such that I can't use a confirm statement or assertion. I
would like to be able to use an error code that directs the user to an
explanation of the cause of the error while also providing a message
that identifies the precise line of code that is throwing the error.
b) using a Stata-defined error code but providing an entirely
different error message. For example, if a user tries to run one of my
programs with an -if- condition that eliminates all of the
observations, I want to throw an error that is similar to, say r(3),
that says "no observations match -if- conditions".
My hunch from the -anything(id = "....")- syntax option is there's
some sort of characteristic or something like that that is used to
generate the error messages, but if so I can't find it.
Thanks in advance,
Brian Karfunkel
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/