From c5dfb9e63bea14717b5144e50411ed1e3d63c0c8 Mon Sep 17 00:00:00 2001 From: Tadeusz Dudkiewicz Date: Thu, 25 Jan 2024 14:06:05 +0100 Subject: [PATCH] uploader: handle X-Clickhouse-Exception-Code header --- uploader/base.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/uploader/base.go b/uploader/base.go index 955b9b88..b0b3ff76 100644 --- a/uploader/base.go +++ b/uploader/base.go @@ -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)) }