88import com .databricks .jdbc .client .DatabricksRetryHandlerException ;
99import com .databricks .jdbc .client .IDatabricksHttpClient ;
1010import com .databricks .jdbc .commons .LogLevel ;
11- import com .databricks .jdbc .commons .util .HttpExecuteExceptionUtil ;
1211import com .databricks .jdbc .commons .util .LoggingUtil ;
1312import com .databricks .jdbc .driver .IDatabricksConnectionContext ;
1413import com .databricks .sdk .core .DatabricksConfig ;
@@ -348,7 +347,7 @@ public CloseableHttpResponse execute(HttpUriRequest request) throws DatabricksHt
348347 try {
349348 return httpClient .execute (request );
350349 } catch (IOException e ) {
351- HttpExecuteExceptionUtil . throwException (e , request );
350+ throwHttpException (e , request );
352351 }
353352 return null ;
354353 }
@@ -361,7 +360,7 @@ public CloseableHttpResponse executeWithoutSSL(HttpUriRequest request)
361360 try {
362361 return httpDisabledSSLClient .execute (request );
363362 } catch (Exception e ) {
364- HttpExecuteExceptionUtil . throwException (e , request );
363+ throwHttpException (e , request );
365364 }
366365 return null ;
367366 }
@@ -413,4 +412,21 @@ public static synchronized void removeInstance(IDatabricksConnectionContext cont
413412 }
414413 }
415414 }
415+
416+ private static void throwHttpException (Exception e , HttpUriRequest request )
417+ throws DatabricksHttpException {
418+ Throwable cause = e ;
419+ while (cause != null ) {
420+ if (cause instanceof DatabricksRetryHandlerException ) {
421+ throw new DatabricksHttpException (cause .getMessage (), cause );
422+ }
423+ cause = cause .getCause ();
424+ }
425+ String errorMsg =
426+ String .format (
427+ "Caught error while executing http request: [%s]. Error Message: [%s]" ,
428+ RequestSanitizer .sanitizeRequest (request ), e );
429+ LoggingUtil .log (LogLevel .ERROR , errorMsg );
430+ throw new DatabricksHttpException (errorMsg , e );
431+ }
416432}
0 commit comments