ยฉ 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabaseโ€ข3y agoโ€ข
9 replies
Oli__

Error handling in Supabase

How do folks like to do error handling in Supabase?

I'm finding I have a lot of code that looks something like:
await supabase.from('quotes')
    .select('*')
    .maybeSingle()
    .then(({ data, error }) => {
      if (error) {
        throw error // this part is annoying boilerplate
      }
      // do interesting stuff with data...
    })
await supabase.from('quotes')
    .select('*')
    .maybeSingle()
    .then(({ data, error }) => {
      if (error) {
        throw error // this part is annoying boilerplate
      }
      // do interesting stuff with data...
    })


What I'd really love to do is avoid the
{data, error}
{data, error}
destructuring, and just use the data objects, and if there's an exception, handle that in the exception path. Is there something I can be doing better?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

SvelteKit + Supabase - Reusing DB calls, wrappers, error handling +
SupabaseSSupabase / help-and-questions
14mo ago
Supabase Auth: why set supabaseResponse in setAll() again?
SupabaseSSupabase / help-and-questions
3mo ago
New Supabase project migration handling?
SupabaseSSupabase / help-and-questions
4y ago
Database save error in supabase
SupabaseSSupabase / help-and-questions
3y ago