Comments (15)
Throwing errors by default, or have that as an option on createClient
, would be a great improvement for us too. We use a lot of rxjs with supabase and regular error throwing would make the whole process more logical. Now we have to remember to write throwOnError
after every query, because otherwise the error will go silent
from supabase-js.
Can we set this as a default behaviour globally via a parameter or smth? This is super unusual behaviour, as SDKs ussually throw errors, otherwise we have to add lots of additional checks around that which doesn't make sense.
from supabase-js.
Does this error handling include programmer errors?
I don't think this should be expected, just catch and rethrow unexpected errors. As you say, handling every possible error would be unwieldy. We should just shape expected errors.
so there's no need to use the data field in place of body.
This one is just a preference. I guess we should decide now what is the more appropriate name for the key. IMO body
seems like a throwback to when we used ajax used to request HTML snippets that would be injected into HTML.
Currently the error handling looks more like this
if (!ok) { // status code is not 2XX
return // abort
}
I'd far prefer this one to look like the suggested change (if (error)
). The term ok
is unexpected, and error
is very clear
from supabase-js.
This is not specific to .rpc()
. You can use .throwOnError()
on .select()
, .insert()
, etc. and it will throw errors instead of returning it in the response object. See the example I linked above.
from supabase-js.
Does this error handling include programmer errors? Say I pass a list to match
where I expect an object, and I use Object.keys
on it. Having to handle each and every kind of such exceptions in JS, with the appropriate error messages, is very painful IMO.
For the record, supabase/postgrest-js#93 uses a fetch polyfill for the HTTP client, so there's no need to use the data
field in place of body
. Currently the error handling looks more like this, though we can shape it to your proposed format:
const { ok, body: products } = await supabase.from('products').select('*')
if (!ok) { // status code is not 2XX
alert(products.message) // PostgREST's error is stored in body (`T | T[] | PostgrestError`) in case of error
return // abort
}
console.log(`Found ${products.length} products.`)
from supabase-js.
Tasks:
- Update
postgrest-js
- Update
gotrue-js
- Update
realtime-js
- Update
supabase-js
- Install new libs
- Change the realtime to work with one socket connection per client
Also solves:
- Client & server side method for validating user auth token : supabase/supabase#147
-
supabase.auth.logout()
throws "Invalid user" error: #15
from supabase-js.
Are there plans to expose the Content-Range
header in the response object?
from supabase-js.
@stupidawesome is there a use case for this? PostgREST supports this, but we haven't really considered having this in. If you just want the COUNT
, there's an open issue for it.
from supabase-js.
const { error, data: products } = await supabase.from('products').select('*')
if (error) {
alert(error.message)
return // abort
}
console.log(`Found ${products.length} products.`)
Do i still need to use try-catch
after using above pattern?
from supabase-js.
You don't - if it throws it might be sign of a postgrest-js bug.
from supabase-js.
You don't - if it throws it might be sign of a postgrest-js bug.
So does supabase return network failure in error
object? I think it does not. So what should i do then?
from supabase-js.
I'm not sure about the other dependencies, but postgrest-js should return network failure in error
. If not, can you create an issue in supabase/postgrest-js along with your client lib verison?
from supabase-js.
import useSWR from 'swr'
function Profile() {
const { data, error } = useSWR('/api/user', fetcher)
if (error) return <div>failed to load</div>
if (!data) return <div>loading...</div>
return <div>hello {data.name}!</div>
}
Here is the text from swr documentation -
**
"If an error is thrown inside fetcher, it will be returned as error by the hook." here is link
**
So if supabase does not throw error and simply return response
object how we will catch supabase error inside swr
?
Will following code work then? Because in following code supabase is not throwing error, so what will be error in following code?
const { data, error } = useSWR(
subheadingId == undefined || userid == undefined
? null
: [`/subheading/${subheadingId}/${userid}`],
async () =>
await supabase.rpc<SharedNotesList>("subheadingg", {
subheadingid: subheadingId,
sharedwith: userid,
}),
);
from supabase-js.
If you want the .rpc()
call to throw errors, you can use .throwOnError()
(example: https://github.com/supabase/postgrest-js/blob/a972b993487fe99990a6be7995f0c6a2dc50b784/test/basic.ts#L136)
from supabase-js.
If you want the
.rpc()
call to throw errors, you can use.throwOnError()
(example: https://github.com/supabase/postgrest-js/blob/a972b993487fe99990a6be7995f0c6a2dc50b784/test/basic.ts#L136)
I am not specific about rpc. take it as general supabase query and answer what i am asking please.
from supabase-js.
Related Issues (20)
- ParserError on return type with aggregate functions HOT 1
- The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers HOT 23
- Extremely dangerous bug: Partial .rpc(...) execution when client is called from Next14 Server Actions. Breaks ACID guarantee.
- List all users (auth schema) not working with local environment HOT 2
- Cannot clear user phone number using `supabase.auth.admin.updateUserById` function HOT 2
- `supabase` client exposes schema details via hint and messages
- Code in supabase-js calls `getSession()`, which now throws a warning when using in combo with ssr HOT 27
- Typescript Types do not reflect new feature: .rpc() with GET #529
- Access data
- Moving for 2.40 to 2.41 or more crash HOT 2
- Execution error with pnpm HOT 2
- Intermittent empty fetch response HOT 1
- Data has no return type when using geojson()
- docs: improve py create a new user HOT 1
- Enabling Post-Signup Email Verification without Blocking User Sign-In on Supabase (Resend) HOT 5
- Nextjs14 with Supabase Auth - AuthApiError: invalid claim: missing sub claim HOT 23
- Max rows in API Settings doesn't work on local development
- chore(deps): Update postgrest-js version to 1.13.0
- Network Error (Fetch) on Expo React Native
- signInAnonymously returns 500 Database error creating anonymous user HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase-js.