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

Support throwing errors instead of returning them #1020

Open
soedirgo opened this issue Jan 14, 2025 · 0 comments · May be fixed by #1022
Open

Support throwing errors instead of returning them #1020

soedirgo opened this issue Jan 14, 2025 · 0 comments · May be fixed by #1022
Labels
enhancement New feature or request

Comments

@soedirgo
Copy link
Member

Feature request

Describe the feature

Add a throwOnError client option to have errors be thrown instead of returning it. As an example, right now we do:

const auth = new AuthClient({ url: AUTH_URL })
const { data, error } = await auth.signUp({ email: '[email protected]', password: 'foobar' })

But with throwOnError we do:

const auth = new AuthClient({ url: AUTH_URL, throwOnError: true })
const { data } = await auth.signUp({ email: '[email protected]', password: 'foobar' })

Additional context

Follows supabase/postgrest-js#188 & supabase/postgrest-js#248

@soedirgo soedirgo added the enhancement New feature or request label Jan 14, 2025
kiwicopple added a commit that referenced this issue Jan 14, 2025
Fixes #1020

Add support for `throwOnError` option in `AuthClient` to throw errors instead of returning them.

* **GoTrueClient Changes:**
  - Add `throwOnError` option to `GoTrueClient` constructor.
  - Modify methods to throw errors when `throwOnError` is true.
  - Update methods like `signUp`, `signInWithPassword`, `updateUser`, and others to throw errors if `throwOnError` is true.

* **AuthClient Changes:**
  - Update `AuthClient` to pass `throwOnError` option to `GoTrueClient`.

* **Tests:**
  - Add tests in `test/GoTrueClient.test.ts` to verify `throwOnError` functionality.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/supabase/auth-js/issues/1020?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant