File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -211,8 +211,16 @@ export class CHDataSource
211
211
resolve ( null ) ;
212
212
}
213
213
} ,
214
- ( e ) => {
215
- reject ( e ) ;
214
+ ( error ) => {
215
+ // Enhance error with more context information
216
+ const enhancedError = {
217
+ ...error ,
218
+ originalError : error ,
219
+ query : query ,
220
+ requestId : requestId
221
+ } ;
222
+
223
+ reject ( enhancedError ) ;
216
224
}
217
225
) ;
218
226
} ) ;
@@ -507,7 +515,23 @@ export class CHDataSource
507
515
508
516
const responses = await Promise . all (
509
517
queries . map ( ( query ) => this . seriesQuery ( query . stmt , query . requestId ) )
510
- ) ;
518
+ ) . catch ( error => {
519
+ // Enhance error message with more details if available
520
+ if ( error ?. data ?. exception ) {
521
+ // ClickHouse exception in data.exception field
522
+ throw new Error ( `Query execution failed: ${ error . data . exception } ` ) ;
523
+ } else if ( error ?. data ?. message ) {
524
+ // Generic message in data.message field
525
+ throw new Error ( `Query execution failed: ${ error . data . message } ` ) ;
526
+ } else if ( error ?. status && error ?. statusText ) {
527
+ // HTTP status with optional response body
528
+ const responseDetails = error ?. data ?
529
+ ( typeof error . data === 'string' ? error . data : JSON . stringify ( error . data ) ) : '' ;
530
+ throw new Error ( `Query execution failed: HTTP ${ error . status } ${ error . statusText } ${ responseDetails ? ': ' + responseDetails : '' } ` ) ;
531
+ } else {
532
+ throw error ;
533
+ }
534
+ } ) ;
511
535
512
536
return this . processQueryResponse ( responses , options , queries )
513
537
}
You can’t perform that action at this time.
0 commit comments