The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Ensure that all POST errors not in RQs are handled
Joshen Limb4df4fdcc9ee
diff --git a/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsxindex a03683c1568..d9baf203b79 100644--- a/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx+++ b/studio/components/interfaces/BillingV2/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx@@ -78,8 +78,8 @@ const AddNewPaymentMethodModal = ({if (intent.error) {return ui.setNotification({category: 'error',- message: intent.error.message,error: intent.error,+ message: `Failed to setup intent: ${intent.error.message}`,})} else {setIntent(intent)diff --git a/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodModal.tsxindex d5383ced140..d970f551535 100644--- a/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodModal.tsx+++ b/studio/components/interfaces/BillingV2/Subscription/Tier/AddNewPaymentMethodModal.tsx@@ -80,8 +80,8 @@ const AddNewPaymentMethodModal = ({if (intent.error) {return ui.setNotification({category: 'error',- message: intent.error.message,error: intent.error,+ message: `Failed to setup intent: ${intent.error.message}`,})} else {setIntent(intent)diff --git a/studio/components/interfaces/Database/Backups/BackupItem.tsx b/studio/components/interfaces/Database/Backups/BackupItem.tsxindex 473f4b837cb..ebd1669560f 100644--- a/studio/components/interfaces/Database/Backups/BackupItem.tsx+++ b/studio/components/interfaces/Database/Backups/BackupItem.tsx@@ -2,7 +2,7 @@ import { PermissionAction } from '@supabase/shared-types/out/constants'import { useQueryClient } from '@tanstack/react-query'import dayjs from 'dayjs'import { useRouter } from 'next/router'-import { FC, useState } from 'react'+import { useState } from 'react'import { confirmAlert } from 'components/to-be-cleaned/ModalsDeprecated/ConfirmModal'import { setProjectStatus } from 'data/projects/projects-query'@@ -11,13 +11,13 @@ import { post } from 'lib/common/fetch'import { API_URL, PROJECT_STATUS } from 'lib/constants'import { Badge, Button, IconDownload } from 'ui'-interface Props {+interface BackupItemProps {projectRef: stringbackup: anyindex: number}-const BackupItem: FC<Props> = ({ projectRef, backup, index }) => {+const BackupItem = ({ projectRef, backup, index }: BackupItemProps) => {const queryClient = useQueryClient()const router = useRouter()const { ui } = useStore()@@ -45,11 +45,11 @@ const BackupItem: FC<Props> = ({ projectRef, backup, index }) => {router.push(`/project/${projectRef}`)}, 3000)})- } catch (error) {+ } catch (error: any) {ui.setNotification({error,category: 'error',- message: `You do not have permission to restore from this backup`,+ message: `Failed to restore from backup: ${error.message}`,})setRestoring(false)}@@ -69,11 +69,11 @@ const BackupItem: FC<Props> = ({ projectRef, backup, index }) => {document.body.removeChild(tempLink)setDownloading(false)- } catch (error) {+ } catch (error: any) {ui.setNotification({error,category: 'error',- message: `You do not have permission to download this backup`,+ message: `Failed to download backup: ${error.message}`,})setDownloading(false)}diff --git a/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx b/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsxindex 1593289f144..435b137676e 100644--- a/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx+++ b/studio/components/interfaces/Organization/NewOrg/NewOrgForm.tsx@@ -96,6 +96,7 @@ const NewOrgForm = ({ onPaymentMethodReset }: NewOrgFormProps) => {if (response.error) {ui.setNotification({+ error: response.error,category: 'error',message: `Failed to create organization: ${response.error?.message ?? response.error}`,})diff --git a/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx b/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsxindex 92041294e39..151e8b0492b 100644--- a/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx+++ b/studio/components/interfaces/Settings/General/Infrastructure/PauseProjectButton.tsx@@ -47,7 +47,7 @@ const PauseProjectButton = () => {ui.setNotification({error: res.error,category: 'error',- message: 'Failed to pause project',+ message: `Failed to pause project: ${res.error.message}`,})setLoading(false)} else {diff --git a/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx b/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsxindex ab04d82fc17..f256b6f70f8 100644--- a/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx+++ b/studio/components/interfaces/Settings/General/Infrastructure/RestartServerButton.tsx@@ -61,7 +61,7 @@ const RestartServerButton = () => {ui.setNotification({error,category: 'error',- message: `Unable to restart ${type}`,+ message: `Unable to restart ${type}: ${error.message}`,})setLoading(false)setServiceToRestart(undefined)diff --git a/studio/components/interfaces/SignIn/ForgotPasswordForm.tsx b/studio/components/interfaces/SignIn/ForgotPasswordForm.tsxindex 309b739a03e..31e17a11be9 100644--- a/studio/components/interfaces/SignIn/ForgotPasswordForm.tsx+++ b/studio/components/interfaces/SignIn/ForgotPasswordForm.tsx@@ -30,7 +30,7 @@ const ForgotPasswordForm = () => {token = captchaResponse?.response ?? null}- const response = await post(`${API_URL}/reset-password`, {+ const { error } = await post(`${API_URL}/reset-password`, {email,hcaptchaToken: token ?? undefined,redirectTo: `${@@ -39,7 +39,6 @@ const ForgotPasswordForm = () => {: process.env.NEXT_PUBLIC_SITE_URL}${BASE_PATH}/reset-password`,})- const error = response.errorif (!error) {ui.setNotification({@@ -56,7 +55,7 @@ const ForgotPasswordForm = () => {ui.setNotification({id: toastId,category: 'error',- message: error.message,+ message: `Failed to send reset email: ${error.message}`,})}}diff --git a/studio/components/interfaces/SignIn/SignUpForm.tsx b/studio/components/interfaces/SignIn/SignUpForm.tsxindex b206e80e8a6..ab6995ad9a9 100644--- a/studio/components/interfaces/SignIn/SignUpForm.tsx+++ b/studio/components/interfaces/SignIn/SignUpForm.tsx@@ -36,7 +36,7 @@ const SignUpForm = () => {resetSignInClicks()- const response = await post(`${API_URL}/signup`, {+ const { error } = await post(`${API_URL}/signup`, {email,password,hcaptchaToken: token ?? null,@@ -46,7 +46,6 @@ const SignUpForm = () => {: process.env.NEXT_PUBLIC_SITE_URL}${BASE_PATH}/sign-in`,})- const error = response.errorif (!error) {ui.setNotification({@@ -63,7 +62,7 @@ const SignUpForm = () => {ui.setNotification({id: toastId,category: 'error',- message: error.message,+ message: `Failed to sign up: ${error.message}`,})}}diff --git a/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx b/studio/components/layouts/ProjectLayout/ProjectPausedState.tsxindex adadffcaae4..e573360e929 100644--- a/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx+++ b/studio/components/layouts/ProjectLayout/ProjectPausedState.tsx@@ -57,9 +57,20 @@ const ProjectPausedState = ({ product }: ProjectPausedStateProps) => {})}- await post(`${API_URL}/projects/${project.ref}/restore`, { kps_enabled: kpsEnabled })- setProjectStatus(queryClient, project.ref, PROJECT_STATUS.RESTORING)- ui.setNotification({ category: 'success', message: 'Restoring project' })+ const { error } = await post(`${API_URL}/projects/${project.ref}/restore`, {+ kps_enabled: kpsEnabled,+ })++ if (error) {+ ui.setNotification({+ category: 'error',+ error,+ message: `Failed to restore project: ${error.message}`,+ })+ } else {+ setProjectStatus(queryClient, project.ref, PROJECT_STATUS.RESTORING)+ ui.setNotification({ category: 'success', message: 'Restoring project' })+ }}return (diff --git a/studio/lib/helpers.ts b/studio/lib/helpers.tsindex 767599d3cfa..71246f591b5 100644--- a/studio/lib/helpers.ts+++ b/studio/lib/helpers.ts@@ -1,6 +1,7 @@-import { v4 as _uuidV4 } from 'uuid'import { post } from 'lib/common/fetch'-import { PASSWORD_STRENGTH, DEFAULT_MINIMUM_PASSWORD_STRENGTH, API_URL } from 'lib/constants'+import { API_URL, DEFAULT_MINIMUM_PASSWORD_STRENGTH, PASSWORD_STRENGTH } from 'lib/constants'+import { toast } from 'react-hot-toast'+import { v4 as _uuidV4 } from 'uuid'export const tryParseJson = (jsonString: any) => {try {@@ -208,6 +209,8 @@ export async function passwordStrength(value: string) {result?.feedback?.warning ? result?.feedback?.warning + '.' : ''} You need a stronger password.`}+ } else {+ toast.error(`Failed to check password strength: ${response.error.message}`)}}}diff --git a/studio/localStores/storageExplorer/StorageExplorerStore.js b/studio/localStores/storageExplorer/StorageExplorerStore.jsindex 8a6d483c631..c36fa4420a3 100644--- a/studio/localStores/storageExplorer/StorageExplorerStore.js+++ b/studio/localStores/storageExplorer/StorageExplorerStore.js@@ -729,15 +729,27 @@ class StorageExplorerStore {`${this.endpoint}/buckets/${this.selectedBucket.id}/objects/public-url`,{ path: formattedPathToFile })- if (!res.error) return res.publicUrl- else console.error('Failed to fetch public file preview', res.error.message)+ if (!res.error) {+ return res.publicUrl+ } else {+ this.ui.setNotification({+ category: 'error',+ message: `Failed to fetch public file preview: ${res.error.message}`,+ })+ }} else {const res = await post(`${this.endpoint}/buckets/${this.selectedBucket.id}/objects/sign`, {path: formattedPathToFile,expiresIn: expiresIn || DEFAULT_EXPIRY,})- if (!res.error) return res.signedUrl- else console.error('Failed to fetch signed url preview', res.error.message)+ if (!res.error) {+ return res.signedUrl+ } else {+ this.ui.setNotification({+ category: 'error',+ message: `Failed to fetch signed url preview: ${res.error.message}`,+ })+ }}return null}@@ -883,7 +895,7 @@ class StorageExplorerStore {return this.ui.setNotification({id: toastId,category: 'error',- message: `Failed to download files from the ${folder.name}`,+ message: `Failed to download files from "${folder.name}"`,})}@@ -902,7 +914,12 @@ class StorageExplorerStore {this.ui.setNotification({id: toastId,category: 'success',- message: `Successfully downloaded folder "${folder.name}"`,+ message:+ downloadedFiles.length === files.length+ ? `Successfully downloaded folder "${folder.name}"`+ : `Downloaded folder "${folder.name}". However, ${+ files.length - downloadedFiles.length+ } files did not download successfully.`,})}@@ -1042,7 +1059,10 @@ class StorageExplorerStore {})if (res.error) {- this.ui.setNotification({ category: 'error', message: res.error.message })+ this.ui.setNotification({+ category: 'error',+ message: `Failed to rename file: ${res.error.message}`,+ })} else {this.ui.setNotification({category: 'success',@@ -1103,6 +1123,12 @@ class StorageExplorerStore {},index)+ } else if (!res.error.message.includes('The user aborted a request')) {+ this.ui.setNotification({+ error: res.error,+ category: 'error',+ message: `Failed to retrieve folder contents from "${folderName}": ${res.error.message}`,+ })}}@@ -1137,6 +1163,12 @@ class StorageExplorerStore {}return col})+ } else if (!res.error.message.includes('The user aborted a request')) {+ this.ui.setNotification({+ error: res.error,+ category: 'error',+ message: `Failed to retrieve folder contents from "${folderName}": ${res.error.message}`,+ })}}@@ -1162,7 +1194,11 @@ class StorageExplorerStore {options,})if (res.error) {- console.error('Error at fetchFoldersByPath:', res.error)+ this.ui.setNotification({+ error: res.error,+ category: 'error',+ message: `Failed to fetch folders: ${res.error.message}`,+ })return []}return resdiff --git a/studio/pages/join/index.tsx b/studio/pages/join/index.tsxindex 0f1a5a1f364..5dcdfc380ef 100644--- a/studio/pages/join/index.tsx+++ b/studio/pages/join/index.tsx@@ -70,6 +70,7 @@ const JoinOrganizationPage = () => {if (response.error) {ui.setNotification({+ error: response.error,category: 'error',message: `Failed to join organization: ${response.error.message}`,})diff --git a/studio/pages/new-with-subscription.tsx b/studio/pages/new-with-subscription.tsxindex abc5597b09c..48ac8eb952a 100644--- a/studio/pages/new-with-subscription.tsx+++ b/studio/pages/new-with-subscription.tsx@@ -55,7 +55,7 @@ const Wizard: NextPageWithLayout = () => {return ui.setNotification({category: 'error',message: intent.error.message,- error: intent.error,+ error: `Failed to retrieve intent: ${intent.error}`,})} else {setIntent(intent)diff --git a/studio/pages/new/[slug].tsx b/studio/pages/new/[slug].tsxindex 54ec6a2d565..fb53b7003d5 100644--- a/studio/pages/new/[slug].tsx+++ b/studio/pages/new/[slug].tsx@@ -226,6 +226,7 @@ const Wizard: NextPageWithLayout = () => {if (response.error) {setNewProjectLoading(false)ui.setNotification({+ error: response.error,category: 'error',message: `Failed to create new project: ${response.error.message}`,})diff --git a/studio/pages/new/index.tsx b/studio/pages/new/index.tsxindex b4e54938c00..f89c1d4883f 100644--- a/studio/pages/new/index.tsx+++ b/studio/pages/new/index.tsx@@ -79,6 +79,7 @@ const Wizard: NextPageWithLayout = () => {if (response.error) {setNewOrgLoading(false)ui.setNotification({+ error: response.error,category: 'error',message: `Failed to create organization: ${response.error?.message ?? response.error}`,})