From 26062af9eedf03e2289ab5450f82b93380f49e3e Mon Sep 17 00:00:00 2001 From: Cheskel Twersky Date: Tue, 5 Nov 2024 14:55:15 +0200 Subject: [PATCH] fix: check the X-ClickHouse-Exception-Code for err code, fixes: #332 --- packages/client-common/src/utils/connection.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/client-common/src/utils/connection.ts b/packages/client-common/src/utils/connection.ts index 62e65eac..b505ceff 100644 --- a/packages/client-common/src/utils/connection.ts +++ b/packages/client-common/src/utils/connection.ts @@ -33,6 +33,14 @@ export function withHttpSettings( } } -export function isSuccessfulResponse(statusCode?: number): boolean { - return Boolean(statusCode && 200 <= statusCode && statusCode < 300) +export function isSuccessfulResponse( + statusCode?: number, + headers: Record = {}, +): boolean { + return Boolean( + statusCode && + 200 <= statusCode && + statusCode < 300 && + !headers['X-ClickHouse-Exception-Code'], + ) }