-
-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
Errors returned do not include a stack trace because they are throwing a plain object instead of an Error
. This makes it annoying to track down the root cause of an error because there's no way to tell where it was thrown from.
To Reproduce
Write a postgrest-js query that returns an error. Notice that error.stack
is undefined and error instanceof Error
is false.
import { PostgrestClient } from 'https://esm.sh/@supabase/[email protected]';
const REST_URL = 'http://localhost:54321/rest/v1';
const postgrest = new PostgrestClient(REST_URL);
try {
const { data } = await postgrest
.from('does_not_exist')
.select('*')
.throwOnError();
console.log(`Got data: ${data}`);
} catch (err) {
console.log(err);
console.log(err.stack);
console.log(err instanceof Error);
}
// {
// code: "42P01",
// details: null,
// hint: null,
// message: 'relation "public.does_not_exist" does not exist'
// }
// undefined
// false
Expected behavior
I expect stack to be set on the result. I think it might be good to return a PostgrestError
that extends Error
with the error details, but also just throwing a plain Error
is probably fine too!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working