The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(Docs): Expose errors on dynamically fetch content under database … (#43976)
Jeremias Menichelli1cde4de0dc89
diff --git a/apps/docs/app/guides/database/database-advisors/page.tsx b/apps/docs/app/guides/database/database-advisors/page.tsxindex bba7532c3de..aedf3e3396b 100644--- a/apps/docs/app/guides/database/database-advisors/page.tsx+++ b/apps/docs/app/guides/database/database-advisors/page.tsx@@ -146,18 +146,27 @@ const urlTransform: (lints: Array<{ path: string }>) => UrlTransformFunction = (const getLints = async () => {const octokit = new Octokit({ request: { fetch: fetchRevalidatePerDay } })- const response = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {- owner: org,- repo: repo,- path: docsDir,- ref: branch,- headers: {- 'X-GitHub-Api-Version': '2022-11-28',- },- })+ let response: Awaited<ReturnType<typeof octokit.request>>+ try {+ response = await octokit.request('GET /repos/{owner}/{repo}/contents/{path}', {+ owner: org,+ repo: repo,+ path: docsDir,+ ref: branch,+ headers: {+ 'X-GitHub-Api-Version': '2022-11-28',+ },+ })+ } catch (err) {+ throw new Error(+ `Failed to fetch database advisors lint list from GitHub (network error): ${err}`+ )+ }if (response.status >= 400) {- throw Error(`Could not get contents of repo ${org}/${repo}`)+ throw new Error(+ `Failed to fetch ${org}/${repo}/contents/${docsDir} docs from GitHub: ${response.status}`+ )}if (!Array.isArray(response.data)) {@@ -170,12 +179,21 @@ const getLints = async () => {const lints = await Promise.all(lintsList.map(async ({ path }) => {- const fileResponse = await fetchRevalidatePerDay(- `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${path}`- )+ let fileResponse: Response+ try {+ fileResponse = await fetchRevalidatePerDay(+ `https://raw.githubusercontent.com/${org}/${repo}/${branch}/${path}`+ )+ } catch (err) {+ throw new Error(+ `Failed to fetch database advisors lint file ${path} from GitHub (network error): ${err}`+ )+ }- if (fileResponse.status >= 400) {- throw Error(`Could not get contents of file ${org}/${repo}/${path}`)+ if (response.status >= 400) {+ throw new Error(+ `Failed to fetch ${org}/${repo}/${branch}/${path} docs from GitHub: ${response.status}`+ )}const content = await fileResponse.text()diff --git a/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx b/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsxindex dae36f2de1e..475818f2e8e 100644--- a/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx+++ b/apps/docs/app/guides/database/extensions/wrappers/[[...slug]]/page.tsx@@ -360,10 +360,22 @@ const getContent = async (params: Params) => {const repoPath = `${org}/${repo}/${tag}/${docsDir}/${remoteFile}`editLink = `${org}/${repo}/blob/${tag}/${docsDir}/${remoteFile}`- const response = await fetch(`https://raw.githubusercontent.com/${repoPath}`, {- cache: 'force-cache',- next: { tags: [REVALIDATION_TAGS.WRAPPERS] },- })+ let response: Response+ try {+ response = await fetch(`https://raw.githubusercontent.com/${repoPath}`, {+ cache: 'force-cache',+ next: { tags: [REVALIDATION_TAGS.WRAPPERS] },+ })+ } catch (err) {+ throw new Error(`Failed to fetch wrappers docs from GitHub (network error): ${err}`)+ }++ if (!response.ok) {+ throw new Error(+ `Failed to fetch wrappers docs from GitHub: ${response.status} ${response.statusText}`+ )+ }+const rawContent = await response.text()assetsBaseUrl = `https://raw.githubusercontent.com/${org}/${repo}/${tag}/docs/assets/`