Skip to content

Commit bbdbe0c

Browse files
Merge main into feature/sql-notebooks
Resolve import conflict: keep both notebook imports and formatError import from the AggregateError fix (PR #39).
2 parents c7ea8e9 + ff04c97 commit bbdbe0c

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/connectionTypes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export type TlsMode = 'off' | 'fingerprint' | 'full';
1111
* instead of Error instances.
1212
*/
1313
export function formatError(error: unknown): string {
14+
if (error instanceof AggregateError && error.errors?.length) {
15+
const inner = error.errors.map(e => formatError(e)).join('; ');
16+
return error.message ? `${error.message}: ${inner}` : inner;
17+
}
1418
if (error instanceof Error) {
1519
// Some errors (e.g. from ws/Node.js net) have an empty message but a useful .code
1620
const code = (error as any).code;

src/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ObjectSearchProvider } from './providers/objectSearchProvider';
1717
import { findStatementAtCursor, splitIntoStatements } from './utils';
1818
import { ExasolNotebookSerializer } from './notebooks/serializer';
1919
import { ExasolNotebookController } from './notebooks/controller';
20+
import { formatError } from './connectionTypes';
2021

2122
// Create output channel for logging
2223
let outputChannel: vscode.OutputChannel;
@@ -628,7 +629,7 @@ async function executeQuery(
628629
}
629630

630631
} catch (error) {
631-
const errorMsg = String(error);
632+
const errorMsg = formatError(error);
632633

633634
if (statements.length > 1) {
634635
output.appendLine(` ❌ Query ${queryNum} failed: ${errorMsg}`);
@@ -855,7 +856,7 @@ async function executeStatement(
855856
}
856857
);
857858
} catch (error) {
858-
const errorMsg = String(error);
859+
const errorMsg = formatError(error);
859860
output.appendLine(`❌ Query failed: ${errorMsg}`);
860861

861862
// Show error in results panel

src/panels/connectionPanel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as vscode from 'vscode';
2-
import { ConnectionManager, ExasolConnection, FingerprintRequiredError, FingerprintMismatchError, normalizeFingerprint, extractFingerprintError, TlsMode } from '../connectionManager';
2+
import { ConnectionManager, ExasolConnection, FingerprintRequiredError, FingerprintMismatchError, normalizeFingerprint, extractFingerprintError, TlsMode, formatError } from '../connectionManager';
33

44
export class ConnectionPanel {
55
public static currentPanel: ConnectionPanel | undefined;
@@ -169,7 +169,7 @@ export class ConnectionPanel {
169169
return;
170170
}
171171

172-
const errorMsg = String(error);
172+
const errorMsg = formatError(error);
173173
this.outputChannel.appendLine(`❌ Connection test failed: ${errorMsg}`);
174174
this._panel.webview.postMessage({ command: 'error', error: errorMsg });
175175
}

src/test/unit/tlsValidation.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,22 @@ suite('formatError', () => {
100100
test('handles numbers', () => {
101101
assert.strictEqual(formatError(42), '42');
102102
});
103+
104+
test('unpacks AggregateError inner errors', () => {
105+
const inner1 = new Error('connect ECONNREFUSED 10.0.0.1:8563');
106+
const inner2 = new Error('connect ETIMEDOUT 10.0.0.2:8563');
107+
const agg = new AggregateError([inner1, inner2], 'All connection attempts failed');
108+
assert.strictEqual(
109+
formatError(agg),
110+
'All connection attempts failed: connect ECONNREFUSED 10.0.0.1:8563; connect ETIMEDOUT 10.0.0.2:8563'
111+
);
112+
});
113+
114+
test('unpacks AggregateError with no message', () => {
115+
const inner = new Error('ECONNREFUSED');
116+
const agg = new AggregateError([inner]);
117+
assert.strictEqual(formatError(agg), 'ECONNREFUSED');
118+
});
103119
});
104120

105121
suite('FingerprintRequiredError', () => {

0 commit comments

Comments
 (0)