Although this sounds like a nice general solution, it will require the
code that gives the error message to be prepared for an autocommand
kicking in. Otherwise, whatever the autocommand does may completely
mess up what the code was doing. We have had many autocommands cause
trouble and still fixing more.
So the code would explicitly check for an autocommand that handles the
error. And since we need to do that, we might as well use a nicer name
than the error number. That also helps for when there can be multiple
errors. E.g. "tagnotfound" is much nicer than matching a list of error
codes. And more error codes could be added later.
An alternative would be to match the error code, but not trigger the
autocommand yet. In the main loop we can then check for the matches
and execute the autocommand. That is a lot safer and simpler.
Nevertheless, you probably want to do something more clever, since after
rebuilding the tags file you would want to search for a match again.
--
hundred-and-one symptoms of being an internet addict:
151. You find yourself engaged to someone you've never actually met,
except through e-mail.