Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: Check the message if it's a string when handling API errors (#26436)

Ivan Vasilov09b4e2b33671
diff --git a/apps/studio/data/fetchers.ts b/apps/studio/data/fetchers.ts
index e9197229044..8176e9678b8 100644
--- a/apps/studio/data/fetchers.ts
+++ b/apps/studio/data/fetchers.ts
@@ -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)