If I understand you, just have your subroutine change a global variable
to be the error message, then look at that on an undef return. You can make
it a list if you want to report more than one error.
You also might want to look into the <error:...> directive for the grammar.