mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 09:55:06 +03:00
fix: Check the message if it's a string when handling API errors (#26436)
Check for string when handling API errors.
This commit is contained in:
1 parent
8886f011c0
commit
09b4e2b336
1 file changed
+6
-4
@@ -151,12 +151,14 @@ export const options: typeof _options = async (url, init) => {
|
||||
}
|
||||
|
||||
export const handleError = (error: any): never => {
|
||||
if (error && error.msg) {
|
||||
throw new Error(error.msg)
|
||||
if (error && typeof error.msg === 'string') {
|
||||
throw new Error(error.msg || 'API error happened while trying to communicate with the server.')
|
||||
}
|
||||
|
||||
if (error && error.message) {
|
||||
throw new Error(error.message)
|
||||
if (error && typeof error.message === 'string') {
|
||||
throw new Error(
|
||||
error.message || 'API error happened while trying to communicate with the server.'
|
||||
)
|
||||
}
|
||||
|
||||
console.error(error.stack)
|
||||
|
||||
Reference in new issue
Block a user