sqliteclidriver: better bubble up stderr errors

This commit is contained in:
mappu 2024-06-30 12:45:23 +12:00
parent d359f42b24
commit abcf7dbfe5
2 changed files with 18 additions and 1 deletions

View File

@ -18,6 +18,22 @@ type processEvent struct {
err error
}
func (pe processEvent) Error() string {
if pe.err != nil {
return pe.err.Error()
}
if pe.evtype == evtypeStderr {
return string(pe.data)
}
return "<no error>"
}
func (pe processEvent) Unwrap() error {
return pe.err
}
//
func ExecEvents(cmd *exec.Cmd) (<-chan processEvent, io.WriteCloser, error) {

View File

@ -251,10 +251,11 @@ func (s *SCStmt) Query(args []driver.Value) (driver.Rows, error) {
pw.CloseWithError(msg.err)
return
}
} else {
// Anything else (process event / stderr)
// Throw
pw.CloseWithError(fmt.Errorf("other thing %#v", msg))
pw.CloseWithError(msg)
return
}