Skip to content

Commit 3815a02

Browse files
author
Roman M
committed
add better error display
1 parent 4f273e5 commit 3815a02

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

src/datasource/datasource.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,16 @@ export class CHDataSource
211211
resolve(null);
212212
}
213213
},
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);
216224
}
217225
);
218226
});
@@ -507,7 +515,23 @@ export class CHDataSource
507515

508516
const responses = await Promise.all(
509517
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+
});
511535

512536
return this.processQueryResponse(responses, options, queries)
513537
}

0 commit comments

Comments
 (0)