From 40141b0f0ae2e323c383ba8a5a0ed52d3ff8b222 Mon Sep 17 00:00:00 2001 From: Sebastiaan Klippert Date: Thu, 26 Oct 2023 22:54:12 +0200 Subject: [PATCH] return original cmd error message in the error string when we return the contents of our own stderr buffer --- wkhtmltopdf.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wkhtmltopdf.go b/wkhtmltopdf.go index 70aa9bb..e1f971e 100644 --- a/wkhtmltopdf.go +++ b/wkhtmltopdf.go @@ -362,11 +362,11 @@ func (pdfg *PDFGenerator) run(ctx context.Context) error { return ctxErr } - // on an error, return the contents of Stderr if it was our own buffer + // on an error, return the error and the contents of Stderr if it was our own buffer // if Stderr was set to a custom writer, just return err if errBuf != nil { if errStr := errBuf.String(); strings.TrimSpace(errStr) != "" { - return errors.New(errStr) + return fmt.Errorf("%s\n%s", errStr, err) } } return err