Unless I am missing something that is right in my face, there is no way I can trap an error message on a page and then fail a transaction.
In the HTTP world, I would very simply:
web_global_verification("Text/IC=An unexpected error has occurred.","Fail=Found","ID=unexpected error", LAST);
If someone can show me how I am being an idiot, please do so.