Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/Proposal: try catch not working on supabase api functions #978

Open
2 tasks done
Shidoengie opened this issue Feb 16, 2024 · 1 comment
Open
2 tasks done

Bug/Proposal: try catch not working on supabase api functions #978

Shidoengie opened this issue Feb 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Shidoengie
Copy link

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

This started when i tried using a try catch on the auth.signUp function but finding out that even though a error is returned catch is never called
I found out that this aplies to a lot of functions and its pretty bad for DX

To Reproduce

try {
  let response = await supabase.auth.signUp({email,password});
  return {success:true};
} catch(err) {
  return {sucess:false}
}

Expected behavior

API functions should return responses and throw errors instead of having a error field that may or may not be null.

System information

  • OS: Windows
    "@supabase/supabase-js": "^2.38.5"
  • Version of Node.js: v21.6.2
@Shidoengie Shidoengie added the bug Something isn't working label Feb 16, 2024
@Nelhoa
Copy link

Nelhoa commented Feb 26, 2024

I think that the whole supabase-js api is working that way.
And I personnaly disliked it at first, but now its seem perfect to me.
Just create your own wrappers to check {data, error} and eventauly throw your own Error class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants