Skip to content

Commit

Permalink
Merge pull request #182 from phil-schreiber/fix/http-response-code
Browse files Browse the repository at this point in the history
convert error header into request error
  • Loading branch information
DoubleDi authored Sep 21, 2024
2 parents 361dc01 + 65e7738 commit 557cddc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"net/http"
"net/url"
"os"
"strings"
"sync/atomic"
"time"

Expand Down Expand Up @@ -293,6 +294,9 @@ func (c *conn) doRequest(ctx context.Context, req *http.Request) (io.ReadCloser,
// response
return nil, newError(string(msg))
}
if errHeader, ok := resp.Header[http.CanonicalHeaderKey("X-ClickHouse-Exception-Code")]; ok {
return nil, newError(strings.Join(errHeader, ", "))
}

return resp.Body, nil
}
Expand Down

0 comments on commit 557cddc

Please sign in to comment.