diff --git a/monitoring.go b/monitoring.go index 7a9998329..04c6a9018 100644 --- a/monitoring.go +++ b/monitoring.go @@ -253,6 +253,20 @@ func (sc *snowflakeConn) rowsForRunningQuery( } return err } + if !resp.Success { + message := resp.Message + code, err := strconv.Atoi(resp.Code) + if err != nil { + code = ErrQueryStatus + message = fmt.Sprintf("%s: (failed to parse original code: %s: %s)", message, resp.Code, err.Error()) + } + return (&SnowflakeError{ + Number: code, + SQLState: resp.Data.SQLState, + Message: message, + QueryID: resp.Data.QueryID, + }).exceptionTelemetry(sc) + } rows.addDownloader(populateChunkDownloader(ctx, sc, resp.Data)) return nil }