mirror of
https://github.com/go-gitea/gitea
synced 2024-09-11 17:06:58 +02:00
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.
This commit is contained in:
parent
a3ab82e592
commit
02ae63297b
5
modules/markup/external/external.go
vendored
5
modules/markup/external/external.go
vendored
@ -4,6 +4,7 @@
|
|||||||
package external
|
package external
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@ -132,11 +133,13 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
|
|||||||
if !p.IsInputFile {
|
if !p.IsInputFile {
|
||||||
cmd.Stdin = input
|
cmd.Stdin = input
|
||||||
}
|
}
|
||||||
|
var stderr bytes.Buffer
|
||||||
cmd.Stdout = output
|
cmd.Stdout = output
|
||||||
|
cmd.Stderr = &stderr
|
||||||
process.SetSysProcAttribute(cmd)
|
process.SetSysProcAttribute(cmd)
|
||||||
|
|
||||||
if err := cmd.Run(); err != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user