Subject: | Impossible to cleanly capture error output |
(A related bug is #31076)
It is currently impossible to capture Parse::RecDescent error output in
a clean way. One way is to redirect STDERR into a (anonymous) filehandle
before loading the module by dup'ing STDERR; another is to re-open
*Parse::RecDescent::STDERR (say, into an in-memory filehandle) after
loading the module and before parsing anything. Neither are very clean
solutions, since both require knowledge of package internals. The latter
would be clean otherwise, but one cannot use local() since the module
uses format().
Details here: http://perlmonks.org/?node_id=710640
Possible solutions:
- Accept a parameter either at module level or parser object level that
makes Parse::RecDescent die() with the error message instead of printing it.
- Or given a filehandle or an object implementing IO::Handle as a
parameter, print to that instead of dup'ing STDERR.