Skip to content

Commit

Permalink
Merge pull request #138 from RTBHOUSE/check-x-clickhouse-exception-code
Browse files Browse the repository at this point in the history
uploader: handle X-Clickhouse-Exception-Code header
  • Loading branch information
Felixoid authored Jan 31, 2024
2 parents 66e33f8 + c5dfb9e commit 67d4abb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions uploader/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ func (u *Base) insertRowBinary(table string, data io.Reader) error {

body, _ := ioutil.ReadAll(resp.Body)

if exceptionCode := resp.Header.Get("X-Clickhouse-Exception-Code"); exceptionCode != "" && exceptionCode != "0" {
return fmt.Errorf("clickhouse exception code %s, response status %d: %s", exceptionCode, resp.StatusCode, string(body))
}

if resp.StatusCode != 200 {
return fmt.Errorf("clickhouse response status %d: %s", resp.StatusCode, string(body))
}
Expand Down

0 comments on commit 67d4abb

Please sign in to comment.