Skip to content

Commit 54f1842

Browse files
committed
🚸 Nicer error handling in post exec queries
When a pre-exec query that creates a table fails, the error is returned to the user. However, a post-exec query to drop the table will still be run and then fail. Now, if the post-exec for dropping fails, it's not printed anymore.
1 parent 551d147 commit 54f1842

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

controller/shell.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,13 @@ func (p *shell) Run(rawQuery string, args ...interface{}) bool {
300300
for _, postExec := range queryData.PostExec {
301301
_, err := queryData.DB.Exec(postExec)
302302
if err != nil {
303-
fmt.Fprintf(tempOutput, "Error running post exec query: %s\n", err.Error())
303+
// Skip the errors for "nu such table" because they're expected
304+
// when a create table pre exec query fails
305+
// The error about why the table doesn't exist is already printed
306+
// so we don't need to print that we cannot drop it
307+
if !strings.Contains(err.Error(), "no such table:") {
308+
fmt.Fprintf(tempOutput, "Error running post exec query: %s\n", err.Error())
309+
}
304310
}
305311
}
306312

0 commit comments

Comments
 (0)