mirror of
https://github.com/t8y2/dbx.git
synced 2026-11-01 08:26:35 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user