Skip to content

Commit

Permalink
Merge pull request #41 from thedadams/better-err-output
Browse files Browse the repository at this point in the history
fix: include stderr when errors are reported
  • Loading branch information
thedadams authored Jun 27, 2024
2 parents 857b9de + 11cb30d commit 4d78314
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 4d78314

Please sign in to comment.