fix(errors): unify backend error protocol and preserve db detail
This commit is contained in:
1 parent
f1617bbd87
commit
c8c40ba839
24 files changed
+1197
-182
No files matched your search
@@ -39,4 +39,24 @@ describe("appendQueryResultSegment spatial merge", () => {
|
||||
// Every row keeps its own SRID; a later page does not overwrite earlier cells.
|
||||
expect(merged.spatial_values).toEqual([[4326], [3857], [3857], [4490]]);
|
||||
});
|
||||
|
||||
it("raises the structured segment error instead of reconstructing from the Error row", () => {
|
||||
const previous = make(1);
|
||||
const segment = {
|
||||
...make(0),
|
||||
execution_error: true as const,
|
||||
rows: [["legacy row text"]],
|
||||
error: {
|
||||
version: 1 as const,
|
||||
code: "DBX-JDBC-4001",
|
||||
messageKey: "backendErrors.jdbc.sqlFailed",
|
||||
messageParams: { stage: "execute" },
|
||||
source: "jdbcAgent" as const,
|
||||
operationOutcome: "unknown" as const,
|
||||
detail: "relation missing_table does not exist",
|
||||
},
|
||||
} as unknown as QueryResult;
|
||||
|
||||
expect(() => appendQueryResultSegment(previous, segment, 100)).toThrow("relation missing_table does not exist");
|
||||
});
|
||||
});
|
||||
@@ -63,7 +63,7 @@ import { useSavedSqlStore } from "@/stores/savedSqlStore";
|
||||
import { useExportTracker } from "@/composables/useExportTracker";
|
||||
import { recordQueryCancellationLatency, resourceLifecycleDiagnostics } from "@/lib/diagnostics/resourceLifecycleDiagnostics";
|
||||
import { appendDebugLog } from "@/lib/backend/debugLog";
|
||||
import { formatError, normalizeBackendError, type BackendError } from "@/lib/backend/errorUtils";
|
||||
import { BackendErrorException, formatError, normalizeBackendError, type BackendError } from "@/lib/backend/errorUtils";
|
||||
import { createSavedSqlEditorPosition, initSavedSqlEditorPositions, restoreSavedSqlEditorPosition, saveSavedSqlEditorPosition } from "@/lib/app/savedSqlEditorPosition";
|
||||
import { ensureSqlExtension } from "@/lib/savedSql/savedSqlFileName";
|
||||
import { resolveSavedSqlExecutionTarget, savedSqlExecutionTargetFromTab, type SavedSqlExecutionTarget, type SavedSqlOpenTargetMode } from "@/lib/savedSql/savedSqlExecutionTarget";
|
||||
@@ -161,7 +161,9 @@ function exactTotalFromIncompletePage(result: QueryResult, pageLimit: number | u
|
||||
}
|
||||
|
||||
export function appendQueryResultSegment(previous: QueryResult, segment: QueryResult, maxRows: number): QueryResult {
|
||||
if (segment.execution_error) throw new Error(String(segment.rows[0]?.[0] ?? "Failed to load the next result segment"));
|
||||
if (segment.execution_error) {
|
||||
throw segment.error ? new BackendErrorException(segment.error) : new BackendErrorException(String(segment.rows[0]?.[0] ?? "Failed to load the next result segment"));
|
||||
}
|
||||
if (previous.columns.length !== segment.columns.length || previous.columns.some((column, index) => column !== segment.columns[index])) {
|
||||
throw new Error("Result columns changed while loading the next segment");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user