From 11cb30db3ebf750096e5fe6315d06ddc1d56f549 Mon Sep 17 00:00:00 2001 From: Donnie Adams Date: Thu, 27 Jun 2024 17:14:36 -0400 Subject: [PATCH] fix: include stderr when errors are reported Signed-off-by: Donnie Adams --- run.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/run.go b/run.go index 2964714..785890b 100644 --- a/run.go +++ b/run.go @@ -42,11 +42,8 @@ type Run struct { func (r *Run) Text() (string, error) { r.lock.Lock() defer r.lock.Unlock() - if r.err != nil { - return "", fmt.Errorf("run encounterd an error: %w with error output: %s", r.err, r.errput) - } - return r.output, nil + return r.output, r.Err() } // Bytes returns the output of the gptscript in bytes. It blocks until the output is ready. @@ -62,7 +59,10 @@ func (r *Run) State() RunState { // Err returns the error that caused the gptscript to fail, if any. func (r *Run) Err() error { - return r.err + if r.err != nil { + return fmt.Errorf("run encounterd an error: %w with error output: %s", r.err, r.errput) + } + return nil } // Program returns the gptscript program for the run.