The direction I pointed Tilmann in is similar, it's a snippet of code buried in the "ad_return_exception_template" proc I added last spring that allows one to return a templated error page.
The idea's the same as your example, i.e. parse and return the template.