Skip to content

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

First round of wrapping RQ errors with handleError (#26384)

Joshen Lim163263c3c515
diff --git a/apps/studio/data/analytics/infra-monitoring-query.ts b/apps/studio/data/analytics/infra-monitoring-query.ts
index 1c3362c5aef..91f1b39b238 100644
--- a/apps/studio/data/analytics/infra-monitoring-query.ts
+++ b/apps/studio/data/analytics/infra-monitoring-query.ts
@@ -54,7 +54,7 @@ export async function getInfraMonitoring(
signal,
})
- if (error) throw handleError(error)
+ if (error) handleError(error)
return data as unknown as AnalyticsData
}
diff --git a/apps/studio/data/analytics/org-daily-compute-stats-query.ts b/apps/studio/data/analytics/org-daily-compute-stats-query.ts
index 60232b64243..1cd459ebcb5 100644
--- a/apps/studio/data/analytics/org-daily-compute-stats-query.ts
+++ b/apps/studio/data/analytics/org-daily-compute-stats-query.ts
@@ -1,9 +1,10 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import dayjs from 'dayjs'
-import { get } from 'data/fetchers'
+
+import { get, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
import type { AnalyticsData } from './constants'
import { analyticsKeys } from './keys'
-import type { ResponseError } from 'types'
export type OrgDailyComputeStatsVariables = {
// API parameters
@@ -34,7 +35,7 @@ export async function getOrgDailyComputeStats(
params: { path: { slug: orgSlug }, query: { projectRef, startDate, endDate } },
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data as AnalyticsData
}
diff --git a/apps/studio/data/analytics/org-daily-stats-query.ts b/apps/studio/data/analytics/org-daily-stats-query.ts
index ba7bb6917d7..e35642b341b 100644
--- a/apps/studio/data/analytics/org-daily-stats-query.ts
+++ b/apps/studio/data/analytics/org-daily-stats-query.ts
@@ -1,5 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import dayjs from 'dayjs'
+
import { get } from 'lib/common/fetch'
import { API_URL } from 'lib/constants'
import type { AnalyticsData } from './constants'
diff --git a/apps/studio/data/analytics/project-daily-stats-query.ts b/apps/studio/data/analytics/project-daily-stats-query.ts
index 593ff9225e2..3cceceb8741 100644
--- a/apps/studio/data/analytics/project-daily-stats-query.ts
+++ b/apps/studio/data/analytics/project-daily-stats-query.ts
@@ -57,7 +57,7 @@ export async function getProjectDailyStats(
signal,
})
- if (error) throw handleError(error)
+ if (error) handleError(error)
return data as unknown as AnalyticsData
}
diff --git a/apps/studio/data/analytics/project-log-requests-count-query.ts b/apps/studio/data/analytics/project-log-requests-count-query.ts
index e5436f71363..310ea107b65 100644
--- a/apps/studio/data/analytics/project-log-requests-count-query.ts
+++ b/apps/studio/data/analytics/project-log-requests-count-query.ts
@@ -1,7 +1,8 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { analyticsKeys } from './keys'
+
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
+import { analyticsKeys } from './keys'
export type ProjectLogRequestsCountVariables = {
projectRef?: string
@@ -18,19 +19,12 @@ export async function getProjectLogRequestsCountStats(
const { data, error } = await get(
'/platform/projects/{ref}/analytics/endpoints/usage.api-requests-count',
{
- params: {
- path: {
- ref: projectRef,
- },
- },
+ params: { path: { ref: projectRef } },
signal,
}
)
- if (error) {
- throw error
- }
-
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/auth/auth-config-query.ts b/apps/studio/data/auth/auth-config-query.ts
index d8a6e34c4a6..3a697a7e054 100644
--- a/apps/studio/data/auth/auth-config-query.ts
+++ b/apps/studio/data/auth/auth-config-query.ts
@@ -22,7 +22,7 @@ export async function getProjectAuthConfig(
signal,
})
- if (error) throw handleError(error)
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/auth/auth-config-update-mutation.ts b/apps/studio/data/auth/auth-config-update-mutation.ts
index 7e0c9f21000..34f73a068d3 100644
--- a/apps/studio/data/auth/auth-config-update-mutation.ts
+++ b/apps/studio/data/auth/auth-config-update-mutation.ts
@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react
import toast from 'react-hot-toast'
import type { components } from 'data/api'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { authKeys } from './keys'
@@ -21,8 +21,7 @@ export async function updateAuthConfig({ projectRef, config }: AuthConfigUpdateV
},
})
- if (error) throw error
-
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/auth/users-query.ts b/apps/studio/data/auth/users-query.ts
index 9b8be7acc5e..474783ec811 100644
--- a/apps/studio/data/auth/users-query.ts
+++ b/apps/studio/data/auth/users-query.ts
@@ -48,7 +48,7 @@ export async function getUsers(
signal,
})
- if (error) throw handleError(error)
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts b/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts
index 179ef255ef8..ab67eb76c55 100644
--- a/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts
+++ b/apps/studio/data/banned-ips/banned-ips-delete-mutations.ts
@@ -1,10 +1,10 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-import { del } from 'data/fetchers'
+import toast from 'react-hot-toast'
+
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { BannedIPKeys } from './keys'
-import toast from 'react-hot-toast'
-
export type IPDeleteVariables = {
projectRef: string
/** can only be one for now */
@@ -19,7 +19,7 @@ export async function deleteBannedIPs({ projectRef, ips }: IPDeleteVariables) {
body: { ipv4_addresses: ips },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/banned-ips/banned-ips-query.ts b/apps/studio/data/banned-ips/banned-ips-query.ts
index 0ac314d39e1..89964f60477 100644
--- a/apps/studio/data/banned-ips/banned-ips-query.ts
+++ b/apps/studio/data/banned-ips/banned-ips-query.ts
@@ -1,4 +1,5 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { BannedIPKeys } from './keys'
diff --git a/apps/studio/data/branches/branch-create-mutation.ts b/apps/studio/data/branches/branch-create-mutation.ts
index c056ae84f0d..168ce19e499 100644
--- a/apps/studio/data/branches/branch-create-mutation.ts
+++ b/apps/studio/data/branches/branch-create-mutation.ts
@@ -1,10 +1,10 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
+import { projectKeys } from 'data/projects/keys'
import type { ResponseError } from 'types'
import { branchKeys } from './keys'
-import { projectKeys } from 'data/projects/keys'
export type BranchCreateVariables = {
projectRef: string
@@ -30,7 +30,7 @@ export async function createBranch({
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/branches/branch-delete-mutation.ts b/apps/studio/data/branches/branch-delete-mutation.ts
index 2ebe359a25f..94b8c0c4b86 100644
--- a/apps/studio/data/branches/branch-delete-mutation.ts
+++ b/apps/studio/data/branches/branch-delete-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { branchKeys } from './keys'
@@ -15,7 +15,7 @@ export async function deleteBranch({ id }: Pick<BranchDeleteVariables, 'id'>) {
params: { path: { branch_id: id } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/branches/branch-query.ts b/apps/studio/data/branches/branch-query.ts
index 4959e155748..c4a6b6ddfbd 100644
--- a/apps/studio/data/branches/branch-query.ts
+++ b/apps/studio/data/branches/branch-query.ts
@@ -16,8 +16,8 @@ export async function getBranch({ id }: BranchVariables, signal?: AbortSignal) {
params: { path: { branch_id: id } },
signal,
})
- if (error) handleError(error)
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/branches/branch-reset-mutation.ts b/apps/studio/data/branches/branch-reset-mutation.ts
index 9637e3347da..4a24da10ff9 100644
--- a/apps/studio/data/branches/branch-reset-mutation.ts
+++ b/apps/studio/data/branches/branch-reset-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { branchKeys } from './keys'
@@ -15,7 +15,7 @@ export async function resetBranch({ id }: Pick<BranchResetVariables, 'id'>) {
params: { path: { branch_id: id } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/branches/branch-update-mutation.ts b/apps/studio/data/branches/branch-update-mutation.ts
index a49d26359c9..9a794603014 100644
--- a/apps/studio/data/branches/branch-update-mutation.ts
+++ b/apps/studio/data/branches/branch-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { branchKeys } from './keys'
@@ -30,7 +30,7 @@ export async function updateBranch({
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/branches/branches-disable-mutation.ts b/apps/studio/data/branches/branches-disable-mutation.ts
index c5185da3899..cccbcd49904 100644
--- a/apps/studio/data/branches/branches-disable-mutation.ts
+++ b/apps/studio/data/branches/branches-disable-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import { projectKeys } from 'data/projects/keys'
import type { ResponseError } from 'types'
import { deleteBranch } from './branch-delete-mutation'
@@ -32,7 +32,7 @@ export async function disableBranching({ branchIds, projectRef }: BranchesDisabl
const { data, error } = await del('/v1/projects/{ref}/branches', {
params: { path: { ref: projectRef } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/branches/branches-query.ts b/apps/studio/data/branches/branches-query.ts
index 67c27347e40..b9ba11d7515 100644
--- a/apps/studio/data/branches/branches-query.ts
+++ b/apps/studio/data/branches/branches-query.ts
@@ -22,7 +22,7 @@ export async function getBranches({ projectRef }: BranchesVariables, signal?: Ab
if ((error as ResponseError).message === 'Preview branching is not enabled for this project.') {
return []
} else {
- throw handleError(error)
+ handleError(error)
}
}
return data
diff --git a/apps/studio/data/config/pgbouncer-enabled-query.ts b/apps/studio/data/config/pgbouncer-enabled-query.ts
index fa176d2e9a6..c1f4658585f 100644
--- a/apps/studio/data/config/pgbouncer-enabled-query.ts
+++ b/apps/studio/data/config/pgbouncer-enabled-query.ts
@@ -1,8 +1,9 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { configKeys } from './keys'
-import type { ResponseError } from 'types'
-import { get } from 'data/fetchers'
+
+import { get, handleError } from 'data/fetchers'
import { IS_PLATFORM } from 'lib/constants'
+import type { ResponseError } from 'types'
+import { configKeys } from './keys'
type PgBouncerVariables = {
projectRef?: string
@@ -16,7 +17,7 @@ export async function getPgBouncerStatus({ projectRef }: PgBouncerVariables, sig
params: { path: { ref: projectRef } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/config/project-settings-query.ts b/apps/studio/data/config/project-settings-query.ts
index 7123a015e65..96a3a82385d 100644
--- a/apps/studio/data/config/project-settings-query.ts
+++ b/apps/studio/data/config/project-settings-query.ts
@@ -1,6 +1,7 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
import type { components } from 'data/api'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { DEFAULT_PROJECT_API_SERVICE_ID } from 'lib/constants'
import type { ResponseError } from 'types'
import { configKeys } from './keys'
@@ -34,7 +35,7 @@ export async function getProjectSettings(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data as unknown as ProjectSettings
}
diff --git a/apps/studio/data/config/project-storage-config-query.ts b/apps/studio/data/config/project-storage-config-query.ts
index ce8f0a09dbe..56cbaf50708 100644
--- a/apps/studio/data/config/project-storage-config-query.ts
+++ b/apps/studio/data/config/project-storage-config-query.ts
@@ -1,9 +1,9 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+
+import { components } from 'data/api'
import { get, handleError } from 'data/fetchers'
-import { API_URL } from 'lib/constants'
-import { configKeys } from './keys'
import type { ResponseError } from 'types'
-import { components } from 'data/api'
+import { configKeys } from './keys'
export type ProjectStorageConfigVariables = {
projectRef?: string
@@ -22,7 +22,7 @@ export async function getProjectStorageConfig(
signal,
})
- if (error) throw handleError(error)
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/config/project-temp-disable-read-only-mutation.ts b/apps/studio/data/config/project-temp-disable-read-only-mutation.ts
index b7c47d4173c..d6942f8c492 100644
--- a/apps/studio/data/config/project-temp-disable-read-only-mutation.ts
+++ b/apps/studio/data/config/project-temp-disable-read-only-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import { usageKeys } from 'data/usage/keys'
import type { ResponseError } from 'types'
@@ -14,7 +14,7 @@ export async function tempDisableReadOnlyMode({ projectRef }: TempDisableReadOnl
params: { path: { ref: projectRef } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/config/project-upgrade-eligibility-query.ts b/apps/studio/data/config/project-upgrade-eligibility-query.ts
index 095b15566c1..f1fec99c611 100644
--- a/apps/studio/data/config/project-upgrade-eligibility-query.ts
+++ b/apps/studio/data/config/project-upgrade-eligibility-query.ts
@@ -1,7 +1,7 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import { IS_PLATFORM } from 'common'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { useProjectByRef } from 'hooks'
import { PROJECT_STATUS } from 'lib/constants/infrastructure'
import type { ResponseError } from 'types'
@@ -30,7 +30,7 @@ export async function getProjectUpgradeEligibility(
params: { path: { ref: projectRef } },
})
- if (error) throw error
+ if (error) handleError(error)
return data as ProjectUpgradeEligibilityResponse
}
diff --git a/apps/studio/data/content/content-delete-mutation.ts b/apps/studio/data/content/content-delete-mutation.ts
index fdae3e32f0f..f8dd7f99efd 100644
--- a/apps/studio/data/content/content-delete-mutation.ts
+++ b/apps/studio/data/content/content-delete-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { contentKeys } from './keys'
@@ -20,7 +20,7 @@ export async function deleteContents(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data.map((x) => x.id)
}
diff --git a/apps/studio/data/content/content-insert-mutation.ts b/apps/studio/data/content/content-insert-mutation.ts
index 4f77b5ab71d..91a74b54fd5 100644
--- a/apps/studio/data/content/content-insert-mutation.ts
+++ b/apps/studio/data/content/content-insert-mutation.ts
@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react
import toast from 'react-hot-toast'
import type { components } from 'data/api'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import type { Content } from './content-query'
import { contentKeys } from './keys'
@@ -35,7 +35,7 @@ export async function insertContent(
},
signal,
})
- if (error) throw error
+ if (error) handleError(error)
// [Joshen] There's an issue with the API codegen due to content endpoint having 2 versions
return data as unknown as InsertContentResponse[]
diff --git a/apps/studio/data/content/content-update-mutation.ts b/apps/studio/data/content/content-update-mutation.ts
index c3faf2908c7..b197e1864bd 100644
--- a/apps/studio/data/content/content-update-mutation.ts
+++ b/apps/studio/data/content/content-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { contentKeys } from './keys'
@@ -21,7 +21,7 @@ export async function updateContent(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/content/content-upsert-mutation.ts b/apps/studio/data/content/content-upsert-mutation.ts
index 50df79e4efe..c1e25bbde61 100644
--- a/apps/studio/data/content/content-upsert-mutation.ts
+++ b/apps/studio/data/content/content-upsert-mutation.ts
@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react
import toast from 'react-hot-toast'
import type { components } from 'data/api'
-import { put } from 'data/fetchers'
+import { handleError, put } from 'data/fetchers'
import type { ResponseError } from 'types'
import type { Content } from './content-query'
import { contentKeys } from './keys'
@@ -35,7 +35,7 @@ export async function upsertContent(
},
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/custom-domains/custom-domains-activate-mutation.ts b/apps/studio/data/custom-domains/custom-domains-activate-mutation.ts
index 091b8e196a3..b898b78d014 100644
--- a/apps/studio/data/custom-domains/custom-domains-activate-mutation.ts
+++ b/apps/studio/data/custom-domains/custom-domains-activate-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { customDomainKeys } from './keys'
@@ -14,7 +14,7 @@ export async function activateCustomDomain({ projectRef }: CustomDomainActivateV
params: { path: { ref: projectRef } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/custom-domains/custom-domains-create-mutation.ts b/apps/studio/data/custom-domains/custom-domains-create-mutation.ts
index b50b0a1bd00..16eb5917d9e 100644
--- a/apps/studio/data/custom-domains/custom-domains-create-mutation.ts
+++ b/apps/studio/data/custom-domains/custom-domains-create-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { customDomainKeys } from './keys'
@@ -19,7 +19,7 @@ export async function createCustomDomain({
body: { custom_hostname: customDomain },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/custom-domains/custom-domains-delete-mutation.ts b/apps/studio/data/custom-domains/custom-domains-delete-mutation.ts
index 2285c138304..d44ccb78abf 100644
--- a/apps/studio/data/custom-domains/custom-domains-delete-mutation.ts
+++ b/apps/studio/data/custom-domains/custom-domains-delete-mutation.ts
@@ -1,6 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-import { del } from 'data/fetchers'
import { toast } from 'react-hot-toast'
+
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { customDomainKeys } from './keys'
@@ -15,7 +16,7 @@ export async function deleteCustomDomain({ projectRef }: CustomDomainDeleteVaria
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/custom-domains/custom-domains-reverify-mutation.ts b/apps/studio/data/custom-domains/custom-domains-reverify-mutation.ts
index 8d7988a2ba1..1489770144f 100644
--- a/apps/studio/data/custom-domains/custom-domains-reverify-mutation.ts
+++ b/apps/studio/data/custom-domains/custom-domains-reverify-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
-
-import { post } from 'data/fetchers'
import { toast } from 'react-hot-toast'
+
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { customDomainKeys } from './keys'
@@ -14,7 +14,7 @@ export async function reverifyCustomDomain({ projectRef }: CustomDomainReverifyV
params: { path: { ref: projectRef } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-columns/database-column-create-mutation.ts b/apps/studio/data/database-columns/database-column-create-mutation.ts
index 28793eaa760..42bbc19cd8c 100644
--- a/apps/studio/data/database-columns/database-column-create-mutation.ts
+++ b/apps/studio/data/database-columns/database-column-create-mutation.ts
@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
import type { components } from 'data/api'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type CreateColumnBody = components['schemas']['CreateColumnBody']
@@ -30,7 +30,7 @@ export async function createDatabaseColumn({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-columns/database-column-delete-mutation.ts b/apps/studio/data/database-columns/database-column-delete-mutation.ts
index b067ea240c9..abdc8c4b2c9 100644
--- a/apps/studio/data/database-columns/database-column-delete-mutation.ts
+++ b/apps/studio/data/database-columns/database-column-delete-mutation.ts
@@ -1,13 +1,13 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
-import type { ResponseError } from 'types'
-import { sqlKeys } from 'data/sql/keys'
import { entityTypeKeys } from 'data/entity-types/keys'
-import type { TableLike } from 'hooks/misc/useTable'
+import { del, handleError } from 'data/fetchers'
+import { sqlKeys } from 'data/sql/keys'
import { tableKeys } from 'data/tables/keys'
import { viewKeys } from 'data/views/keys'
+import type { TableLike } from 'hooks/misc/useTable'
+import type { ResponseError } from 'types'
export type DatabaseColumnDeleteVariables = {
projectRef: string
@@ -36,7 +36,7 @@ export async function deleteDatabaseColumn({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-columns/database-column-update-mutation.ts b/apps/studio/data/database-columns/database-column-update-mutation.ts
index 17ba65de6a5..29721a3831d 100644
--- a/apps/studio/data/database-columns/database-column-update-mutation.ts
+++ b/apps/studio/data/database-columns/database-column-update-mutation.ts
@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
import type { components } from 'data/api'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
export type UpdateColumnBody = components['schemas']['UpdateColumnBody']
@@ -33,7 +33,7 @@ export async function updateDatabaseColumn({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-extensions/database-extension-disable-mutation.ts b/apps/studio/data/database-extensions/database-extension-disable-mutation.ts
index a1e3d029136..008579d79b2 100644
--- a/apps/studio/data/database-extensions/database-extension-disable-mutation.ts
+++ b/apps/studio/data/database-extensions/database-extension-disable-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseExtensionsKeys } from './keys'
@@ -28,7 +28,7 @@ export async function disableDatabaseExtension({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-extensions/database-extension-enable-mutation.ts b/apps/studio/data/database-extensions/database-extension-enable-mutation.ts
index 4f88ed07992..66d5e97e648 100644
--- a/apps/studio/data/database-extensions/database-extension-enable-mutation.ts
+++ b/apps/studio/data/database-extensions/database-extension-enable-mutation.ts
@@ -1,10 +1,10 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
+import { executeSql } from 'data/sql/execute-sql-query'
import type { ResponseError } from 'types'
import { databaseExtensionsKeys } from './keys'
-import { executeSql } from 'data/sql/execute-sql-query'
export type DatabaseExtensionEnableVariables = {
projectRef: string
@@ -49,7 +49,7 @@ export async function enableDatabaseExtension({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-extensions/database-extensions-query.ts b/apps/studio/data/database-extensions/database-extensions-query.ts
index 2d57aecf21d..fee2b370ed3 100644
--- a/apps/studio/data/database-extensions/database-extensions-query.ts
+++ b/apps/studio/data/database-extensions/database-extensions-query.ts
@@ -1,5 +1,5 @@
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseExtensionsKeys } from './keys'
@@ -30,7 +30,7 @@ export async function getDatabaseExtensions(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-functions/database-functions-create-mutation.ts b/apps/studio/data/database-functions/database-functions-create-mutation.ts
index b43c65ea3ef..4481062a688 100644
--- a/apps/studio/data/database-functions/database-functions-create-mutation.ts
+++ b/apps/studio/data/database-functions/database-functions-create-mutation.ts
@@ -1,10 +1,9 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
-import type { ResponseError } from 'types'
+import { handleError, post } from 'data/fetchers'
+import type { Dictionary, ResponseError } from 'types'
import { databaseFunctionsKeys } from './keys'
-import type { Dictionary } from 'types'
export type DatabaseFunctionCreateVariables = {
projectRef: string
@@ -39,7 +38,7 @@ export async function createDatabaseFunction({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-functions/database-functions-delete-mutation.ts b/apps/studio/data/database-functions/database-functions-delete-mutation.ts
index 1b6a6c3191e..02714fa3f36 100644
--- a/apps/studio/data/database-functions/database-functions-delete-mutation.ts
+++ b/apps/studio/data/database-functions/database-functions-delete-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseFunctionsKeys } from './keys'
@@ -28,7 +28,7 @@ export async function deleteDatabaseFunction({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-functions/database-functions-query.ts b/apps/studio/data/database-functions/database-functions-query.ts
index 4e42d9a43c1..d57ef25bea5 100644
--- a/apps/studio/data/database-functions/database-functions-query.ts
+++ b/apps/studio/data/database-functions/database-functions-query.ts
@@ -1,8 +1,8 @@
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import type { components } from 'data/api'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseFunctionsKeys } from './keys'
-import type { components } from 'data/api'
export type DatabaseFunctionsVariables = {
projectRef?: string
@@ -26,7 +26,7 @@ export async function getDatabaseFunctions(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
// [Joshen] API codegen is wrong, its matching Edge functions type to database functions
return data as unknown as DatabaseFunction[]
}
diff --git a/apps/studio/data/database-functions/database-functions-update-mutation.ts b/apps/studio/data/database-functions/database-functions-update-mutation.ts
index 0010303742c..953f036c3e5 100644
--- a/apps/studio/data/database-functions/database-functions-update-mutation.ts
+++ b/apps/studio/data/database-functions/database-functions-update-mutation.ts
@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react
import { toast } from 'react-hot-toast'
import type { components } from 'data/api'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseFunctionsKeys } from './keys'
@@ -32,7 +32,7 @@ export async function updateDatabaseFunction({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-policies/database-policies-query.ts b/apps/studio/data/database-policies/database-policies-query.ts
index 4dcc3618de8..3213dac2061 100644
--- a/apps/studio/data/database-policies/database-policies-query.ts
+++ b/apps/studio/data/database-policies/database-policies-query.ts
@@ -1,6 +1,6 @@
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databasePoliciesKeys } from './keys'
@@ -32,7 +32,7 @@ export async function getDatabasePolicies(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-policies/database-policy-create-mutation.ts b/apps/studio/data/database-policies/database-policy-create-mutation.ts
index eb23a4e6117..2a6b74e28a6 100644
--- a/apps/studio/data/database-policies/database-policy-create-mutation.ts
+++ b/apps/studio/data/database-policies/database-policy-create-mutation.ts
@@ -1,10 +1,10 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import type { components } from 'data/api'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databasePoliciesKeys } from './keys'
-import type { components } from 'data/api'
type CreatePolicyBody = components['schemas']['CreatePolicyBody']
@@ -31,7 +31,7 @@ export async function createDatabasePolicy({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-policies/database-policy-delete-mutation.ts b/apps/studio/data/database-policies/database-policy-delete-mutation.ts
index d312458f630..bebcdeeb98a 100644
--- a/apps/studio/data/database-policies/database-policy-delete-mutation.ts
+++ b/apps/studio/data/database-policies/database-policy-delete-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databasePoliciesKeys } from './keys'
@@ -28,7 +28,7 @@ export async function deleteDatabasePolicy({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-policies/database-policy-update-mutation.ts b/apps/studio/data/database-policies/database-policy-update-mutation.ts
index 075873820c1..5ba38b3bab1 100644
--- a/apps/studio/data/database-policies/database-policy-update-mutation.ts
+++ b/apps/studio/data/database-policies/database-policy-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databasePoliciesKeys } from './keys'
@@ -36,7 +36,7 @@ export async function updateDatabasePolicy({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-publications/database-publications-create-mutation.ts b/apps/studio/data/database-publications/database-publications-create-mutation.ts
index 2945ce701e0..5dbdec0b619 100644
--- a/apps/studio/data/database-publications/database-publications-create-mutation.ts
+++ b/apps/studio/data/database-publications/database-publications-create-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databasePublicationsKeys } from './keys'
@@ -45,7 +45,7 @@ export async function createDatabasePublication({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-publications/database-publications-query.ts b/apps/studio/data/database-publications/database-publications-query.ts
index 72e376d8604..4aaaed2b4a2 100644
--- a/apps/studio/data/database-publications/database-publications-query.ts
+++ b/apps/studio/data/database-publications/database-publications-query.ts
@@ -1,5 +1,5 @@
import { UseQueryOptions, useQuery } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databasePublicationsKeys } from './keys'
@@ -30,7 +30,7 @@ export async function getDatabasePublications(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database-publications/database-publications-update-mutation.ts b/apps/studio/data/database-publications/database-publications-update-mutation.ts
index 42f98b61e30..b613ac27ad8 100644
--- a/apps/studio/data/database-publications/database-publications-update-mutation.ts
+++ b/apps/studio/data/database-publications/database-publications-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databasePublicationsKeys } from './keys'
@@ -46,7 +46,7 @@ export async function updateDatabasePublication({
headers,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/backup-download-mutation.ts b/apps/studio/data/database/backup-download-mutation.ts
index 8c9d4a832b1..9239036b5a4 100644
--- a/apps/studio/data/database/backup-download-mutation.ts
+++ b/apps/studio/data/database/backup-download-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { Backup } from './backup-restore-mutation'
@@ -23,7 +23,7 @@ export async function downloadBackup({ ref, backup }: BackupDownloadVariables) {
status: 'deprecated',
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/backup-restore-mutation.ts b/apps/studio/data/database/backup-restore-mutation.ts
index 8fb0ff7fb7f..bc034f62f1c 100644
--- a/apps/studio/data/database/backup-restore-mutation.ts
+++ b/apps/studio/data/database/backup-restore-mutation.ts
@@ -1,9 +1,9 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
-import type { ResponseError } from 'types'
import type { components } from 'data/api'
+import { handleError, post } from 'data/fetchers'
+import type { ResponseError } from 'types'
export type BackupRestoreVariables = {
ref: string
@@ -27,7 +27,7 @@ export async function restoreFromBackup({ ref, backup }: BackupRestoreVariables)
params: { path: { ref } },
body: { id: backup.id },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/backups-query.ts b/apps/studio/data/database/backups-query.ts
index d2c38ae3555..f1ebb9dde03 100644
--- a/apps/studio/data/database/backups-query.ts
+++ b/apps/studio/data/database/backups-query.ts
@@ -1,9 +1,9 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import type { components } from 'data/api'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseKeys } from './keys'
-import type { components } from 'data/api'
export type BackupsVariables = {
projectRef?: string
@@ -19,7 +19,7 @@ export async function getBackups({ projectRef }: BackupsVariables, signal?: Abor
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/database-password-reset-mutation.ts b/apps/studio/data/database/database-password-reset-mutation.ts
index 832fe483098..11b89ea0e52 100644
--- a/apps/studio/data/database/database-password-reset-mutation.ts
+++ b/apps/studio/data/database/database-password-reset-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import { projectKeys } from 'data/projects/keys'
import type { ResponseError } from 'types'
@@ -18,7 +18,7 @@ export async function resetDatabasePassword({ ref, password }: DatabasePasswordR
body: { password },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/enable-physical-backups-mutation.ts b/apps/studio/data/database/enable-physical-backups-mutation.ts
index 2dd09381db0..7f532c62bf9 100644
--- a/apps/studio/data/database/enable-physical-backups-mutation.ts
+++ b/apps/studio/data/database/enable-physical-backups-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type EnablePhysicalBackupsVariables = {
@@ -12,7 +12,7 @@ export async function enablePhysicalBackups({ ref }: EnablePhysicalBackupsVariab
const { data, error } = await post('/platform/database/{ref}/backups/enable-physical-backups', {
params: { path: { ref } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/hooks-enable-mutation.ts b/apps/studio/data/database/hooks-enable-mutation.ts
index 68563763610..e5e0c715850 100644
--- a/apps/studio/data/database/hooks-enable-mutation.ts
+++ b/apps/studio/data/database/hooks-enable-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { invalidateSchemasQuery } from './schemas-query'
@@ -13,7 +13,7 @@ export async function enableDatabaseWebhooks({ ref }: HooksEnableVariables) {
const { data, error } = await post('/platform/database/{ref}/hook-enable', {
params: { path: { ref } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/pitr-restore-mutation.ts b/apps/studio/data/database/pitr-restore-mutation.ts
index 8089acb85d9..b98199af658 100644
--- a/apps/studio/data/database/pitr-restore-mutation.ts
+++ b/apps/studio/data/database/pitr-restore-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type PitrRestoreVariables = {
@@ -14,7 +14,7 @@ export async function restoreFromPitr({ ref, recovery_time_target_unix }: PitrRe
params: { path: { ref } },
body: { recovery_time_target_unix },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/database/pooling-configuration-update-mutation.ts b/apps/studio/data/database/pooling-configuration-update-mutation.ts
index 96bcc57afff..2a18a3e0fd7 100644
--- a/apps/studio/data/database/pooling-configuration-update-mutation.ts
+++ b/apps/studio/data/database/pooling-configuration-update-mutation.ts
@@ -2,7 +2,7 @@ import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react
import { toast } from 'react-hot-toast'
import type { components } from 'data/api'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { databaseKeys } from './keys'
@@ -22,7 +22,7 @@ export async function updatePoolingConfiguration({
body: { default_pool_size, pool_mode },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/documents/document-query.ts b/apps/studio/data/documents/document-query.ts
index a9a674e61fc..05dfee7cf7a 100644
--- a/apps/studio/data/documents/document-query.ts
+++ b/apps/studio/data/documents/document-query.ts
@@ -1,5 +1,5 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { documentKeys } from './keys'
@@ -21,8 +21,8 @@ export async function getDocument({ orgSlug, docType }: DocumentVariables, signa
signal,
}
)
- if (error) throw error
+ if (error) handleError(error)
return data as { fileUrl: string }
}
diff --git a/apps/studio/data/feedback/feedback-send.ts b/apps/studio/data/feedback/feedback-send.ts
index 6bd5b084e49..0d38ca943f3 100644
--- a/apps/studio/data/feedback/feedback-send.ts
+++ b/apps/studio/data/feedback/feedback-send.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type SendFeedbackVariables = {
@@ -27,7 +27,7 @@ export async function sendFeedback({
pathname,
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/feedback/support-ticket-send.ts b/apps/studio/data/feedback/support-ticket-send.ts
index aa7ad8f6450..ddc6831cf31 100644
--- a/apps/studio/data/feedback/support-ticket-send.ts
+++ b/apps/studio/data/feedback/support-ticket-send.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type sendSupportTicketVariables = {
@@ -52,7 +52,7 @@ export async function sendSupportTicket({
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/feedback/upgrade-survey-send.ts b/apps/studio/data/feedback/upgrade-survey-send.ts
index 2aa263d80db..01b63abb697 100644
--- a/apps/studio/data/feedback/upgrade-survey-send.ts
+++ b/apps/studio/data/feedback/upgrade-survey-send.ts
@@ -3,7 +3,6 @@ import toast from 'react-hot-toast'
// import { post } from 'lib/common/fetch'
import { handleError, post } from 'data/fetchers'
-import { API_URL } from 'lib/constants'
import type { ResponseError } from 'types'
export type SendUpgradeFeedbackVariables = {
diff --git a/apps/studio/data/fetchers.ts b/apps/studio/data/fetchers.ts
index 88df2a923bb..c6f2a649e6c 100644
--- a/apps/studio/data/fetchers.ts
+++ b/apps/studio/data/fetchers.ts
@@ -1,9 +1,9 @@
+import * as Sentry from '@sentry/nextjs'
import { API_URL, IS_PLATFORM } from 'lib/constants'
import { getAccessToken } from 'lib/gotrue'
import { uuidv4 } from 'lib/helpers'
import createClient from 'openapi-fetch'
import type { paths } from './api' // generated from openapi-typescript
-import type { ResponseError } from 'types'
const DEFAULT_HEADERS = {
'Content-Type': 'application/json',
@@ -150,6 +150,23 @@ export const options: typeof _options = async (url, init) => {
})
}
-export const handleError = (error: ResponseError) => {
- throw new Error(error.message)
+export const handleError = (error: any): never => {
+ if (error && error.msg) {
+ throw new Error(error.msg)
+ }
+
+ if (error && error.message) {
+ throw new Error(error.message)
+ }
+
+ // the error doesn't have a message or msg property, so we can't throw it as an error. Log it via Sentry so that we can
+ // add handling for it.
+ console.error(error.stack)
+ Sentry.captureMessage(
+ `Unable to throw an object as error. The object has the following keys: ${Object.keys(error)}.`
+ )
+
+ // throw a generic error if we don't know what the error is. The message is intentionally vague because it might show
+ // up in the UI.
+ throw new Error('API error happened while trying to communicate with the server.')
}
diff --git a/apps/studio/data/integrations/github-authorization-create-mutation.ts b/apps/studio/data/integrations/github-authorization-create-mutation.ts
index 53e73b0f524..55f24d21fab 100644
--- a/apps/studio/data/integrations/github-authorization-create-mutation.ts
+++ b/apps/studio/data/integrations/github-authorization-create-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import toast from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type GitHubAuthorizationCreateVariables = {
@@ -13,7 +13,7 @@ export async function createGitHubAuthorization({ code }: GitHubAuthorizationCre
body: { code },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/github-branch-check-query.ts b/apps/studio/data/integrations/github-branch-check-query.ts
index 9ac754fe668..21388e8ac55 100644
--- a/apps/studio/data/integrations/github-branch-check-query.ts
+++ b/apps/studio/data/integrations/github-branch-check-query.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
export type GithubBranchVariables = {
@@ -26,7 +26,7 @@ export async function checkGithubBranchValidity(
}
)
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/github-branches-query.ts b/apps/studio/data/integrations/github-branches-query.ts
index 9b621eab61d..342238466c5 100644
--- a/apps/studio/data/integrations/github-branches-query.ts
+++ b/apps/studio/data/integrations/github-branches-query.ts
@@ -1,7 +1,7 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { integrationKeys } from './keys'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
+import { integrationKeys } from './keys'
export type GitHubBranchesVariables = {
connectionId?: number
@@ -18,7 +18,7 @@ export async function getGitHubBranches(
signal,
})
- if (error) throw new Error((error as ResponseError).message)
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/github-connection-create-mutation.ts b/apps/studio/data/integrations/github-connection-create-mutation.ts
index 569827c5f5e..7448653a018 100644
--- a/apps/studio/data/integrations/github-connection-create-mutation.ts
+++ b/apps/studio/data/integrations/github-connection-create-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import type { GitHubConnectionCreateVariables } from './integrations.types'
import { integrationKeys } from './keys'
@@ -10,10 +10,8 @@ export async function createGitHubConnection({ connection }: GitHubConnectionCre
const { data, error } = await post('/platform/integrations/github/connections', {
body: connection,
})
- if (error) {
- throw error
- }
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/github-connection-delete-mutation.ts b/apps/studio/data/integrations/github-connection-delete-mutation.ts
index 85c59938212..1c68ea88d2f 100644
--- a/apps/studio/data/integrations/github-connection-delete-mutation.ts
+++ b/apps/studio/data/integrations/github-connection-delete-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { integrationKeys } from './keys'
@@ -15,8 +15,8 @@ export async function deleteConnection({ connectionId }: DeleteVariables, signal
params: { path: { connection_id: String(connectionId) } },
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/github-connection-update-mutation.ts b/apps/studio/data/integrations/github-connection-update-mutation.ts
index 9424cdd73c4..737970d0ff4 100644
--- a/apps/studio/data/integrations/github-connection-update-mutation.ts
+++ b/apps/studio/data/integrations/github-connection-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { integrationKeys } from './keys'
@@ -21,8 +21,8 @@ export async function updateConnection(
signal,
body: { workdir, supabase_changes_only: supabaseChangesOnly },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/github-connections-query.ts b/apps/studio/data/integrations/github-connections-query.ts
index b173daa6a39..44c05d20391 100644
--- a/apps/studio/data/integrations/github-connections-query.ts
+++ b/apps/studio/data/integrations/github-connections-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { integrationKeys } from './keys'
@@ -22,7 +22,8 @@ export async function getGitHubConnections(
},
signal,
})
- if (error) throw new Error((error as ResponseError).message)
+
+ if (error) handleError(error)
return data.connections
}
diff --git a/apps/studio/data/integrations/github-repositories-query.ts b/apps/studio/data/integrations/github-repositories-query.ts
index d03f7d06448..b58e13bf980 100644
--- a/apps/studio/data/integrations/github-repositories-query.ts
+++ b/apps/studio/data/integrations/github-repositories-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { integrationKeys } from './keys'
@@ -8,8 +8,8 @@ export async function getGitHubRepositories(signal?: AbortSignal) {
const { data, error } = await get('/platform/integrations/github/repositories', {
signal,
})
- if (error) throw new Error((error as ResponseError).message)
+ if (error) handleError(error)
// [Alaister]: temp fix until we have a proper response type
return (data as any).repositories
}
diff --git a/apps/studio/data/integrations/integrations-query.ts b/apps/studio/data/integrations/integrations-query.ts
index cae79239865..346ba379ca7 100644
--- a/apps/studio/data/integrations/integrations-query.ts
+++ b/apps/studio/data/integrations/integrations-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { integrationKeys } from './keys'
@@ -9,10 +9,8 @@ export async function getIntegrations(signal?: AbortSignal) {
params: { query: { integration_name: '' } },
signal,
})
- if (error) {
- throw error
- }
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/integrations-vercel-connection-sync-envs-mutation.ts b/apps/studio/data/integrations/integrations-vercel-connection-sync-envs-mutation.ts
index ebd690f9908..00b6111290f 100644
--- a/apps/studio/data/integrations/integrations-vercel-connection-sync-envs-mutation.ts
+++ b/apps/studio/data/integrations/integrations-vercel-connection-sync-envs-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type IntegrationsVercelConnectionSyncEnvsVariables = {
@@ -19,10 +19,8 @@ export async function syncEnvsIntegrationsVercelConnection({
},
}
)
- if (error) {
- throw error
- }
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/integrations-vercel-connections-create-mutation.ts b/apps/studio/data/integrations/integrations-vercel-connections-create-mutation.ts
index 21f9050ddb7..24a14e36a7c 100644
--- a/apps/studio/data/integrations/integrations-vercel-connections-create-mutation.ts
+++ b/apps/studio/data/integrations/integrations-vercel-connections-create-mutation.ts
@@ -1,11 +1,11 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
+import { useIntegrationInstallationSnapshot } from 'state/integration-installation'
import type { ResponseError } from 'types'
-import { integrationKeys } from './keys'
import type { IntegrationConnectionsCreateVariables } from './integrations.types'
-import { useIntegrationInstallationSnapshot } from 'state/integration-installation'
+import { integrationKeys } from './keys'
export async function createIntegrationVercelConnections({
organizationIntegrationId,
@@ -21,10 +21,8 @@ export async function createIntegrationVercelConnections({
},
},
})
- if (error) {
- throw error
- }
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/integrations/integrations-vercel-projects-query.ts b/apps/studio/data/integrations/integrations-vercel-projects-query.ts
index a7568f0539a..82a5201cab7 100644
--- a/apps/studio/data/integrations/integrations-vercel-projects-query.ts
+++ b/apps/studio/data/integrations/integrations-vercel-projects-query.ts
@@ -1,7 +1,5 @@
-import { useQuery, useQueryClient, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { useCallback } from 'react'
-import type { VercelFramework } from './integrations.types'
+import { useQuery, UseQueryOptions } from '@tanstack/react-query'
+import { get, handleError } from 'data/fetchers'
import { integrationKeys } from './keys'
export type VercelProjectsVariables = {
@@ -31,10 +29,7 @@ export async function getVercelProjects(
}
)
- if (error) {
- throw error
- }
-
+ if (error) handleError(error)
return data.projects
}
diff --git a/apps/studio/data/integrations/vercel-connection-update-mutate.ts b/apps/studio/data/integrations/vercel-connection-update-mutate.ts
index 57fb2c1b5d9..1d5c5904de4 100644
--- a/apps/studio/data/integrations/vercel-connection-update-mutate.ts
+++ b/apps/studio/data/integrations/vercel-connection-update-mutate.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import type { UpdateConnectionPayload } from './integrations.types'
import { integrationKeys } from './keys'
@@ -16,7 +16,7 @@ export async function updateVercelConnection({ id, envSyncTargets }: UpdateConne
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/invoices/invoice-query.ts b/apps/studio/data/invoices/invoice-query.ts
index 3ad78d6d1db..bcf912e072a 100644
--- a/apps/studio/data/invoices/invoice-query.ts
+++ b/apps/studio/data/invoices/invoice-query.ts
@@ -1,5 +1,5 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { invoicesKeys } from './keys'
@@ -15,7 +15,7 @@ export async function getInvoice({ id }: InvoiceVariables, signal?: AbortSignal)
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/invoices/invoices-overdue-query.ts b/apps/studio/data/invoices/invoices-overdue-query.ts
index a5597c76e1d..df541684173 100644
--- a/apps/studio/data/invoices/invoices-overdue-query.ts
+++ b/apps/studio/data/invoices/invoices-overdue-query.ts
@@ -1,7 +1,7 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { invoicesKeys } from './keys'
import type { components } from 'data/api'
+import { get, handleError } from 'data/fetchers'
+import { invoicesKeys } from './keys'
export type OverdueInvoicesResponse = components['schemas']['OverdueInvoiceCount']
@@ -9,10 +9,8 @@ export async function getOverdueInvoices(signal?: AbortSignal) {
const { data, error } = await get('/platform/stripe/invoices/overdue', {
signal,
})
- if (error) {
- throw error
- }
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/invoices/invoices-query.ts b/apps/studio/data/invoices/invoices-query.ts
index f6248b0827b..54519b4c297 100644
--- a/apps/studio/data/invoices/invoices-query.ts
+++ b/apps/studio/data/invoices/invoices-query.ts
@@ -1,5 +1,5 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { invoicesKeys } from './keys'
@@ -25,7 +25,7 @@ export async function getInvoices(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/invoices/org-invoice-upcoming-query.ts b/apps/studio/data/invoices/org-invoice-upcoming-query.ts
index cc6533fbcd1..b92a7f6eb87 100644
--- a/apps/studio/data/invoices/org-invoice-upcoming-query.ts
+++ b/apps/studio/data/invoices/org-invoice-upcoming-query.ts
@@ -1,8 +1,8 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { invoicesKeys } from './keys'
-import type { ResponseError } from 'types'
import { PricingMetric } from 'data/analytics/org-daily-stats-query'
+import { get, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { invoicesKeys } from './keys'
export type UpcomingInvoiceVariables = {
orgSlug?: string
@@ -49,7 +49,7 @@ export async function getUpcomingInvoice(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data as unknown as UpcomingInvoiceResponse
}
diff --git a/apps/studio/data/misc/reset-password-mutation.ts b/apps/studio/data/misc/reset-password-mutation.ts
index f4b4de7e327..17eeba8201b 100644
--- a/apps/studio/data/misc/reset-password-mutation.ts
+++ b/apps/studio/data/misc/reset-password-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type ResetPasswordVariables = {
@@ -16,7 +16,7 @@ export async function resetPassword({ email, hcaptchaToken, redirectTo }: ResetP
body: { email, hcaptchaToken, redirectTo },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/misc/signup-mutation.ts b/apps/studio/data/misc/signup-mutation.ts
index 4713a950cdb..c29f2e6eaa8 100644
--- a/apps/studio/data/misc/signup-mutation.ts
+++ b/apps/studio/data/misc/signup-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type SignUpVariables = {
@@ -17,7 +17,7 @@ export async function signup({ email, password, hcaptchaToken, redirectTo }: Sig
body: { email, password, hcaptchaToken, redirectTo },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/network-restrictions/network-restrictions-query.ts b/apps/studio/data/network-restrictions/network-restrictions-query.ts
index 678266f74cc..bc480fce19c 100644
--- a/apps/studio/data/network-restrictions/network-restrictions-query.ts
+++ b/apps/studio/data/network-restrictions/network-restrictions-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import { networkRestrictionKeys } from './keys'
export type NetworkRestrictionsVariables = { projectRef?: string }
@@ -38,7 +38,7 @@ export async function getNetworkRestrictions(
status: '',
} as NetworkRestrictionsResponse
} else {
- throw error
+ handleError(error)
}
}
diff --git a/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts b/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts
index 52b93336630..5163e7b2f28 100644
--- a/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts
+++ b/apps/studio/data/network-restrictions/network-retrictions-apply-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { networkRestrictionKeys } from './keys'
@@ -23,7 +23,7 @@ export async function applyNetworkRestrictions({
body: { dbAllowedCidrs, dbAllowedCidrsV6 },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/notifications/notifications-dismiss-mutation.ts b/apps/studio/data/notifications/notifications-dismiss-mutation.ts
index f7d4c9c7349..c28280161df 100644
--- a/apps/studio/data/notifications/notifications-dismiss-mutation.ts
+++ b/apps/studio/data/notifications/notifications-dismiss-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { notificationKeys } from './keys'
@@ -11,7 +11,8 @@ export type NotificationsDismissVariables = {
export async function dismissNotifications({ ids }: NotificationsDismissVariables) {
const { data, error } = await del('/platform/notifications', { body: { ids } })
- if (error) throw error
+
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/notifications/notifications-update-mutation.ts b/apps/studio/data/notifications/notifications-update-mutation.ts
index e601f8ba38c..263a6e5c04e 100644
--- a/apps/studio/data/notifications/notifications-update-mutation.ts
+++ b/apps/studio/data/notifications/notifications-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { notificationKeys } from './keys'
@@ -12,7 +12,8 @@ export type NotificationsUpdateVariables = {
export async function updateNotifications({ ids }: NotificationsUpdateVariables) {
// @ts-ignore
const { data, error } = await patch('/platform/notifications', { body: { ids } })
- if (error) throw error
+
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/notifications/notifications-v2-archive-all-mutation.ts b/apps/studio/data/notifications/notifications-v2-archive-all-mutation.ts
index a8401911315..9d245509a44 100644
--- a/apps/studio/data/notifications/notifications-v2-archive-all-mutation.ts
+++ b/apps/studio/data/notifications/notifications-v2-archive-all-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { notificationKeys } from './keys'
@@ -9,7 +9,8 @@ export async function archiveAllNotifications() {
const { data, error } = await patch('/platform/notifications/archive-all', {
headers: { Version: '2' },
})
- if (error) throw error
+
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/notifications/notifications-v2-query.ts b/apps/studio/data/notifications/notifications-v2-query.ts
index 669400d4faa..847c03ce95c 100644
--- a/apps/studio/data/notifications/notifications-v2-query.ts
+++ b/apps/studio/data/notifications/notifications-v2-query.ts
@@ -1,5 +1,5 @@
import { useInfiniteQuery, UseInfiniteQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { components } from 'data/api'
import type { ResponseError } from 'types'
@@ -53,7 +53,7 @@ export async function getNotifications(options: NotificationVariables, signal?:
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/notifications/notifications-v2-summary-query.ts b/apps/studio/data/notifications/notifications-v2-summary-query.ts
index 8204845afb4..15992ea0090 100644
--- a/apps/studio/data/notifications/notifications-v2-summary-query.ts
+++ b/apps/studio/data/notifications/notifications-v2-summary-query.ts
@@ -1,7 +1,7 @@
import type { Notification } from '@supabase/shared-types/out/notifications'
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { notificationKeys } from './keys'
@@ -11,7 +11,7 @@ export async function getNotificationsSummary(signal?: AbortSignal) {
const { data, error } = await get('/platform/notifications/summary', {
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/notifications/notifications-v2-update-mutation.ts b/apps/studio/data/notifications/notifications-v2-update-mutation.ts
index 4ed3818a37e..0063d408e0b 100644
--- a/apps/studio/data/notifications/notifications-v2-update-mutation.ts
+++ b/apps/studio/data/notifications/notifications-v2-update-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
export type NotificationsUpdateVariables = {
@@ -16,7 +16,7 @@ export async function updateNotifications({ ids, status }: NotificationsUpdateVa
}),
headers: { Version: '2' },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/open-api/api-spec-query.ts b/apps/studio/data/open-api/api-spec-query.ts
index bbb362f2f59..0ecd8d0014d 100644
--- a/apps/studio/data/open-api/api-spec-query.ts
+++ b/apps/studio/data/open-api/api-spec-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { openApiKeys } from './keys'
@@ -21,7 +21,8 @@ export async function getOpenAPISpec({ projectRef }: OpenAPISpecVariables, signa
params: { path: { ref: projectRef } },
signal,
})
- if (error) throw error
+
+ if (error) handleError(error)
const tables = data.definitions
? Object.entries(data.definitions).map(([key, table]: any) => ({
diff --git a/apps/studio/data/organizations/organization-billing-subscription-preview.ts b/apps/studio/data/organizations/organization-billing-subscription-preview.ts
index 3d2ba7a852b..80420ba0384 100644
--- a/apps/studio/data/organizations/organization-billing-subscription-preview.ts
+++ b/apps/studio/data/organizations/organization-billing-subscription-preview.ts
@@ -1,8 +1,8 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { post } from 'data/fetchers'
-import { organizationKeys } from './keys'
-import type { ResponseError } from 'types'
+import { handleError, post } from 'data/fetchers'
import type { SubscriptionTier } from 'data/subscriptions/types'
+import type { ResponseError } from 'types'
+import { organizationKeys } from './keys'
export type OrganizationBillingSubscriptionPreviewVariables = {
organizationSlug?: string
@@ -63,7 +63,7 @@ export async function previewOrganizationBillingSubscription({
}
)
- if (error) throw error
+ if (error) handleError(error)
return data as OrganizationBillingSubscriptionPreviewResponse
}
diff --git a/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts b/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts
index 9e171d74c85..a4d59a9646d 100644
--- a/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts
+++ b/apps/studio/data/organizations/organization-by-fly-organization-id-mutation.ts
@@ -17,7 +17,7 @@ export async function getOrganizationByFlyOrgId({
const { data, error } = await get('/platform/organizations/fly/{fly_organization_id}', {
params: { path: { fly_organization_id: flyOrganizationId } },
})
- if (error) throw handleError(error)
+ if (error) handleError(error)
return data as { slug: string }
}
diff --git a/apps/studio/data/organizations/organization-create-mutation.ts b/apps/studio/data/organizations/organization-create-mutation.ts
index daa82c1e998..28bef2019c9 100644
--- a/apps/studio/data/organizations/organization-create-mutation.ts
+++ b/apps/studio/data/organizations/organization-create-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import { permissionKeys } from 'data/permissions/keys'
import type { ResponseError } from 'types'
import { organizationKeys } from './keys'
@@ -32,7 +32,7 @@ export async function createOrganization({
},
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/organizations/organization-delete-mutation.ts b/apps/studio/data/organizations/organization-delete-mutation.ts
index e075389270e..e54654adfa8 100644
--- a/apps/studio/data/organizations/organization-delete-mutation.ts
+++ b/apps/studio/data/organizations/organization-delete-mutation.ts
@@ -1,10 +1,10 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
+import { permissionKeys } from 'data/permissions/keys'
import type { ResponseError } from 'types'
import { organizationKeys } from './keys'
-import { permissionKeys } from 'data/permissions/keys'
export type OrganizationDeleteVariables = {
slug: string
@@ -14,7 +14,7 @@ export async function deleteOrganization({ slug }: OrganizationDeleteVariables)
const { data, error } = await del('/platform/organizations/{slug}', {
params: { path: { slug } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/organizations/organization-join-decline-mutation.ts b/apps/studio/data/organizations/organization-join-decline-mutation.ts
index 397ceeb0cad..abe1c4748f7 100644
--- a/apps/studio/data/organizations/organization-join-decline-mutation.ts
+++ b/apps/studio/data/organizations/organization-join-decline-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { del } from 'data/fetchers'
+import { del, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
export type OrganizationJoinDeclineVariables = {
@@ -17,7 +17,7 @@ export async function declineJoinOrganization({
// @ts-ignore [Joshen] API spec might be wrong here
params: { path: { slug }, query: { invited_id } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/organizations/organization-join-mutation.ts b/apps/studio/data/organizations/organization-join-mutation.ts
index 3f07c2d4757..3755bdb9445 100644
--- a/apps/studio/data/organizations/organization-join-mutation.ts
+++ b/apps/studio/data/organizations/organization-join-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
import { organizationKeys } from './keys'
@@ -14,7 +14,7 @@ export async function joinOrganization({ slug, token }: OrganizationJoinVariable
const { data, error } = await post('/platform/organizations/{slug}/members/join', {
params: { path: { slug }, query: { token } },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/organizations/organization-join-token-validation-query.ts b/apps/studio/data/organizations/organization-join-token-validation-query.ts
index cbc28c9d778..1fe1f2d8b03 100644
--- a/apps/studio/data/organizations/organization-join-token-validation-query.ts
+++ b/apps/studio/data/organizations/organization-join-token-validation-query.ts
@@ -1,6 +1,6 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
import type { components } from 'data/api'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { organizationKeys } from './keys'
@@ -20,7 +20,7 @@ export async function validateTokenInformation(
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/organizations/organization-members-query.ts b/apps/studio/data/organizations/organization-members-query.ts
index 581f0a2dd50..90a7bf069f1 100644
--- a/apps/studio/data/organizations/organization-members-query.ts
+++ b/apps/studio/data/organizations/organization-members-query.ts
@@ -1,7 +1,7 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import type { components } from 'data/api'
-import { get } from 'data/fetchers'
+import { get, handleError } from 'data/fetchers'
import type { ResponseError } from 'types'
import { organizationKeys } from './keys'
@@ -29,8 +29,8 @@ export async function getOrganizationMembers(
const { data: orgMembers, error: orgMembersError } = members
const { data: orgInvites, error: orgInvitesError } = invites
- if (orgMembersError) throw orgMembersError
- if (orgInvitesError) throw orgInvitesError
+ if (orgMembersError) handleError(orgMembersError)
+ if (orgInvitesError) handleError(orgInvitesError)
// Remap invite data to look like existing members data
const invitedMembers = orgInvites.map((invite) => {
diff --git a/apps/studio/data/organizations/organization-payment-method-setup-intent-mutation.ts b/apps/studio/data/organizations/organization-payment-method-setup-intent-mutation.ts
index d6f581f32ca..2eca3ada4da 100644
--- a/apps/studio/data/organizations/organization-payment-method-setup-intent-mutation.ts
+++ b/apps/studio/data/organizations/organization-payment-method-setup-intent-mutation.ts
@@ -1,7 +1,7 @@
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { post } from 'data/fetchers'
+import { handleError, post } from 'data/fetchers'
import type { ResponseError } from 'types'
export type OrganizationPaymentMethodSetupIntentVariables = {
@@ -19,7 +19,7 @@ export async function setupPaymentMethodIntent({
// @ts-ignore [Joshen] API seems to be having the wrong spec
body: { hcaptchaToken },
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/organizations/organization-update-mutation.ts b/apps/studio/data/organizations/organization-update-mutation.ts
index b89d3ac700c..f6d9c9ba31b 100644
--- a/apps/studio/data/organizations/organization-update-mutation.ts
+++ b/apps/studio/data/organizations/organization-update-mutation.ts
@@ -1,10 +1,10 @@
import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'
import { toast } from 'react-hot-toast'
-import { patch } from 'data/fetchers'
+import type { components } from 'data/api'
+import { handleError, patch } from 'data/fetchers'
import type { ResponseError } from 'types'
import { organizationKeys } from './keys'
-import type { components } from 'data/api'
export type OrganizationUpdateVariables = {
slug: string
@@ -30,7 +30,7 @@ export async function updateOrganization({
body: payload,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts b/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts
index 63dcc99cf13..5ad93765553 100644
--- a/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts
+++ b/apps/studio/data/projects/project-by-fly-extension-id-mutation.ts
@@ -17,7 +17,7 @@ export async function getProjectByFlyExtensionId({
const { data, error } = await get('/platform/projects/fly/{fly_extension_id}', {
params: { path: { fly_extension_id: flyExtensionId } },
})
- if (error) throw handleError(error)
+ if (error) handleError(error)
return data as { ref: string }
}
diff --git a/apps/studio/data/usage/org-usage-query.ts b/apps/studio/data/usage/org-usage-query.ts
index d7a2216c325..d23cb9ba5b5 100644
--- a/apps/studio/data/usage/org-usage-query.ts
+++ b/apps/studio/data/usage/org-usage-query.ts
@@ -1,8 +1,9 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { usageKeys } from './keys'
-import type { ResponseError } from 'types'
+
import type { components } from 'data/api'
+import { get, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { usageKeys } from './keys'
export type OrgUsageVariables = {
orgSlug?: string
@@ -26,7 +27,7 @@ export async function getOrgUsage(
},
signal,
})
- if (error) throw error
+ if (error) handleError(error)
return data
}
diff --git a/apps/studio/data/usage/resource-warnings-query.ts b/apps/studio/data/usage/resource-warnings-query.ts
index 78817a1f3af..1c4e495bb2a 100644
--- a/apps/studio/data/usage/resource-warnings-query.ts
+++ b/apps/studio/data/usage/resource-warnings-query.ts
@@ -1,14 +1,14 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get } from 'data/fetchers'
-import { usageKeys } from './keys'
-import type { ResponseError } from 'types'
-import type { components } from 'data/api'
import { IS_PLATFORM } from 'common'
+import type { components } from 'data/api'
+import { get, handleError } from 'data/fetchers'
+import type { ResponseError } from 'types'
+import { usageKeys } from './keys'
export async function getResourceWarnings(signal?: AbortSignal) {
const { data, error } = await get(`/platform/projects-resource-warnings`, { signal })
- if (error) throw error
+ if (error) handleError(error)
return data
}