aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Tran <jon@allspice.io>2023-01-13 15:41:23 -0500
committerGitHub <noreply@github.com>2023-01-13 20:41:23 +0000
commit02ae63297bd622bf453a930ce8dd180a58e11ed9 (patch)
treed96716c11d3ca0ccfedca72f74cd03fa123343ae
parenta3ab82e5924196632f1731ae3ef2099bf9d39501 (diff)
downloadgitea-02ae63297bd622bf453a930ce8dd180a58e11ed9.tar.gz
gitea-02ae63297bd622bf453a930ce8dd180a58e11ed9.zip
Log STDERR of external renderer when it fails (#22442)
When using an external renderer, STDOUT is expected to be HTML. But anything written to STDERR is currently ignored. In cases where the renderer fails, I would like to log any error messages that the external program outputs to STDERR.
-rw-r--r--modules/markup/external/external.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go
index f47776690f..ffbb6da4da 100644
--- a/modules/markup/external/external.go
+++ b/modules/markup/external/external.go
@@ -4,6 +4,7 @@
package external
import (
+ "bytes"
"fmt"
"io"
"os"
@@ -132,11 +133,13 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
if !p.IsInputFile {
cmd.Stdin = input
}
+ var stderr bytes.Buffer
cmd.Stdout = output
+ cmd.Stderr = &stderr
process.SetSysProcAttribute(cmd)
if err := cmd.Run(); err != nil {
- return fmt.Errorf("%s render run command %s %v failed: %w", p.Name(), commands[0], args, err)
+ return fmt.Errorf("%s render run command %s %v failed: %w\nStderr: %s", p.Name(), commands[0], args, err, stderr.String())
}
return nil
}