Skip to content

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

chore(refacto): throw error instances (#35617)

Andrew Valleteau71b261932e39
diff --git a/apps/studio/data/fetchers.ts b/apps/studio/data/fetchers.ts
index beec442de72..37b807f428b 100644
--- a/apps/studio/data/fetchers.ts
+++ b/apps/studio/data/fetchers.ts
@@ -63,13 +63,11 @@ function pgMetaGuard(request: Request) {
// If there is no valid `x-connection-encrypted`, pg-meta will necesseraly fail to connect to the target database
// in such case, we save the hops and throw a 421 response instead
if (!isValidConnString(request.headers.get('x-connection-encrypted'))) {
- // TODO: Maybe here add a sentry warning to monitor how often this happen
- // Simulate a 421 response by throwing an error
- throw {
- code: 421,
- message: 'x-connection-encrypted header is required for /platform/pg-meta/ requests',
- requestId: request.headers.get('X-Request-Id'),
- }
+ throw new ResponseError(
+ 'x-connection-encrypted header is required for /platform/pg-meta/ requests',
+ 400,
+ request.headers.get('X-Request-Id') ?? undefined
+ )
}
}
return request
diff --git a/packages/pg-meta/src/query/Query.utils.ts b/packages/pg-meta/src/query/Query.utils.ts
index dd4170230fb..ee39000b24d 100644
--- a/packages/pg-meta/src/query/Query.utils.ts
+++ b/packages/pg-meta/src/query/Query.utils.ts
@@ -39,7 +39,7 @@ export function deleteQuery(
}
) {
if (!filters || filters.length === 0) {
- throw { message: 'no filters for this delete query' }
+ throw new Error('no filters for this delete query')
}
let query = `delete from ${queryTable(table)}`
const { returning, enumArrayColumns } = options ?? {}
@@ -64,7 +64,7 @@ export function insertQuery(
}
) {
if (!values || values.length === 0) {
- throw { message: 'no value to insert' }
+ throw new Error('no value to insert')
}
const { returning, enumArrayColumns } = options ?? {}
const queryColumns = Object.keys(values[0])
@@ -134,7 +134,7 @@ export function updateQuery(
) {
const { filters, returning, enumArrayColumns } = options ?? {}
if (!filters || filters.length === 0) {
- throw { message: 'no filters for this update query' }
+ throw new Error('no filters for this update query')
}
const queryColumns = Object.keys(value)
.map((x) => ident(x))
diff --git a/tests/studio-tests/tests/common-functionality/logs.spec.ts b/tests/studio-tests/tests/common-functionality/logs.spec.ts
index 02397b57784..d272a9d37e9 100644
--- a/tests/studio-tests/tests/common-functionality/logs.spec.ts
+++ b/tests/studio-tests/tests/common-functionality/logs.spec.ts
@@ -8,6 +8,7 @@ const LOGS_PAGES = [
]
test.describe('Logs', async () => {
+ test.describe.configure({ retries: 5 })
for (const logPage of LOGS_PAGES) {
test.describe(`${logPage.label} logs page`, () => {
test('can navigate to logs page', async ({ page, ref }) => {