Improve error handling in run by preserving additional error details

This commit is contained in:
MartinBraquet
2026-04-02 14:07:02 +02:00
parent d121c92708
commit df775e9aa3

View File

@@ -66,7 +66,9 @@ export async function run<T>(
export async function run<T>(q: PromiseLike<PostgrestSingleResponse<T> | PostgrestResponse<T>>) {
const {data, count, error} = await q
if (error != null) {
throw error
const err = new Error(error.message)
Object.assign(err, error) // copies code, details, hint onto the Error
throw err
} else {
return {data, count}
}