Pygmentize: report stderr when exit code != 0 and stdout is empty

Most python error messages are reported to stderr rather than stdout. In
the event of a catastrophic failure executing the Pygments binary we are
likely to need to report stderr so that folks can debug the problem with
the executable.

Bug: T364249
Change-Id: Id5e5dbc515fdcdeb6eec61aacbbb9cbeddc79fab
This commit is contained in:
Bryan Davis 2024-05-16 17:27:08 -06:00
parent e96144ff92
commit ee1a6c20d7

View file

@ -298,7 +298,11 @@ class Pygmentize {
$output = $result->getStdout();
if ( $result->getExitCode() != 0 ) {
throw new PygmentsException( $output );
if ( $output === "" || $output === null ) {
// Stdout was empty, report stderr instead
$output = $result->getStderr();
}
throw new PygmentsException( (string)$output );
}
return $output;