fix: catch error response

This commit is contained in:
Ayo 2023-05-12 22:11:46 +02:00
parent 79279e4ab1
commit c9e7c103c7

View file

@ -9,7 +9,15 @@ import Layout from "../layouts/layout.astro";
const params = getParams(Astro.url); const params = getParams(Astro.url);
const url: string = params?.url || ""; const url: string = params?.url || "";
const article = isURL(url) && (await extract(url)); let article;
try {
article = isURL(url) && (await extract(url));
} catch {
article = {
title: "Something is not right",
content: "The articl extractor did not get any result",
};
}
--- ---
<Layout title={article?.title}> <Layout title={article?.title}>