Skip to content

Commit

Permalink
Check for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
macneale4 committed Feb 28, 2025
1 parent 27e95f0 commit 0830e3b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go/cmd/dolt/commands/engine/sql_print.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func prettyPrintResultsWithSummary(ctx *sql.Context, resultFormat PrintResultFor
var err error
var numRows int

// Function to print results. A function is required because we need to wrap the whole process in a swap of
// IO streams. This is done with cli.ExecuteWithStdioRestored, which requires a resultless function. As
// a result, we need to depend on side effects to numRows and err to determine if it was successful.
printEm := func() {
writerStream := cli.CliOut
if pageResults {
Expand Down Expand Up @@ -126,6 +129,9 @@ func prettyPrintResultsWithSummary(ctx *sql.Context, resultFormat PrintResultFor
} else {
printEm()
}
if err != nil {
return err
}

// if there is no row data and result format is JSON, then create empty JSON.
if resultFormat == FormatJson && numRows == 0 {
Expand Down

0 comments on commit 0830e3b

Please sign in to comment.