From 1bff9480ccbba0a75a6fbe7d08eaba520d40123d Mon Sep 17 00:00:00 2001 From: Lorenz Sieben Date: Wed, 16 Oct 2024 21:21:07 +0200 Subject: [PATCH] Fail safer in getAppMeta --- src/pages/p/[platform]/[appId]/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/p/[platform]/[appId]/index.ts b/src/pages/p/[platform]/[appId]/index.ts index 3d84236..d57b04b 100644 --- a/src/pages/p/[platform]/[appId]/index.ts +++ b/src/pages/p/[platform]/[appId]/index.ts @@ -19,7 +19,13 @@ export const POST: APIRoute = async ({ params, redirect, currentLocale, clientAd const token = nanoid(); - const appMeta = await getAppMeta({ platform, appId, language: currentLocale || 'en' }); + let appMeta; + try { + appMeta = await getAppMeta({ platform, appId, language: currentLocale || 'en' }); + } catch (e) { + // TODO: Proper error handling + return new Response('Getting the apps’s metadata failed.', { status: 500 }); + } if (!appMeta) return new Response('App not found.', { status: 404 }); const { token: analysisToken } = await startAnalysis(platform, appMeta.appId);