fix: improve database error message extraction for queries

- frontend: use e.message instead of String(e) in toErrorResult to avoid
  "Error: " prefix for HTTP-mode errors, matching connectionErrorMessage
- frontend: apply same fix to MongoDocBrowser error display
- backend(postgres): use pg_error_to_string across all query execution
  paths (execute, execute_batch, copy_out, copy_in) to extract DbError
  details instead of generic transport-layer errors

Other databases (MySQL, SQL Server, SQLite, DuckDB) already include
server-level error details in their native Error::to_string().
This commit is contained in:
t8y2
2026-05-27 15:40:28 +08:00
parent 7717eae5ff
commit dafed47b07
3 changed files with 14 additions and 13 deletions
@@ -167,7 +167,7 @@ async function load() {
documents.value = result.documents.map(asRecord);
total.value = result.total;
} catch (e: unknown) {
error.value = String(e);
error.value = e instanceof Error ? e.message : String(e);
} finally {
loading.value = false;
}
@@ -354,7 +354,7 @@ async function saveDoc() {
editJson.value = JSON.stringify(documents.value[selectedIdx.value], null, 2);
}
} catch (e: unknown) {
error.value = String(e);
error.value = e instanceof Error ? e.message : String(e);
}
}
@@ -371,7 +371,7 @@ async function applyDeleteDoc(idx: number) {
}
await load();
} catch (e: unknown) {
error.value = String(e);
error.value = e instanceof Error ? e.message : String(e);
}
}
+2 -1
View File
@@ -403,9 +403,10 @@ export const useQueryStore = defineStore("query", () => {
}
function toErrorResult(e: any): NonNullable<QueryTab["result"]> {
const message = e instanceof Error ? e.message : String(e);
return {
columns: ["Error"],
rows: [[String(e)]],
rows: [[message]],
affected_rows: 0,
execution_time_ms: 0,
};