Skip to content

Commit 4d78314

Browse files
authored
Merge pull request #41 from thedadams/better-err-output
fix: include stderr when errors are reported
2 parents 857b9de + 11cb30d commit 4d78314

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

run.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ type Run struct {
4242
func (r *Run) Text() (string, error) {
4343
r.lock.Lock()
4444
defer r.lock.Unlock()
45-
if r.err != nil {
46-
return "", fmt.Errorf("run encounterd an error: %w with error output: %s", r.err, r.errput)
47-
}
4845

49-
return r.output, nil
46+
return r.output, r.Err()
5047
}
5148

5249
// 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 {
6259

6360
// Err returns the error that caused the gptscript to fail, if any.
6461
func (r *Run) Err() error {
65-
return r.err
62+
if r.err != nil {
63+
return fmt.Errorf("run encounterd an error: %w with error output: %s", r.err, r.errput)
64+
}
65+
return nil
6666
}
6767

6868
// Program returns the gptscript program for the run.

0 commit comments

Comments
 (0)