Skip to content

Commit

Permalink
Fix atoi error. (#110)
Browse files Browse the repository at this point in the history
* the result can return just Data field, so we parse a code as an error only if it is set as an error.
  • Loading branch information
mtoader authored and rajsigma committed Sep 8, 2023
1 parent b6de16a commit e8b9f43
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,22 @@ func (sc *snowflakeConn) rowsForRunningQuery(
}
return err
}
// the result response sometimes contains only Data and not anything else. We parse the error code only
// if it's set in the response
if !resp.Success && resp.Code != "" {
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
}
Expand Down

0 comments on commit e8b9f43

Please sign in to comment.