mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-02 22:15:23 -04:00
Improve error handling in run by preserving additional error details
This commit is contained in:
@@ -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}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user