-
Notifications
You must be signed in to change notification settings - Fork 128
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
Directly throw Supabase error in server utility functions #412
base: main
Are you sure you want to change the base?
Directly throw Supabase error in server utility functions #412
Conversation
👷 Deploy request for n3-supabase pending review.Visit the deploys page to approve it
|
@philliphartin could you provide an example where this would be useful? |
Sure, let's say you're building an API endpoint that handles invitations to join a platform. The endpoint could be capable of determining if the invitation link is being opened by an authenticated user or not with the serverSupabaseUser utility. Example
If the user is available, then they can associate the invitation to that user. |
Sorry for the late response on this. Currently it is also possible to catch the error thrown with |
Please take a look at https://github.com/unjs/h3/blob/2d941d3cfb1dddf543d48abe23d13488c88c7432/src/error.ts#L82 the H3Error extends the Error instance so it's exactly the same but it better when dealing with HTTP errors. |
Re-opening as I believe it might be best to use |
That seems like a good idea. Would you like me to make those changes and commit back to the PR? |
@philliphartin I think you can keep this one and rename it. |
createError
usage in server utilities, using direct throw instead
Remove opinionated use of
createError
in favor of direct throw for better error handlingTypes of changes
Description
This change removes the use of
createError
and replaces it with a directthrow
. This modification allows downstream users more flexibility in catching and handling errors, fitting the specific needs of their applications.Why is this change required? What problem does it solve?
The previous implementation using
createError
restricted how errors could be caught and handled by downstream users. By directly throwing errors, developers now have the ability to catch and manage these errors in a way that best suits their application's requirements.Resolves: N/A
Checklist: