From 7afd23665fad41adf3668473347cb35f28faf32d Mon Sep 17 00:00:00 2001 From: Sjaak Schilperoort Date: Fri, 4 Mar 2022 15:38:33 +0100 Subject: [PATCH] Fix for SvgUri and SvgCssUri crashing on non-existing svg files (#1503) Fix for interpreting an HTML error response as svg data, and then crash when this cannot be parsed as well formed XML --- src/xml.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/xml.tsx b/src/xml.tsx index 828f104e..879e35de 100644 --- a/src/xml.tsx +++ b/src/xml.tsx @@ -124,7 +124,10 @@ export function SvgXml(props: XmlProps) { export async function fetchText(uri: string) { const response = await fetch(uri); - return await response.text(); + if (response.ok) { + return await response.text(); + } + throw new Error(`Fetching ${uri} failed with status ${response.status}`); } export function SvgUri(props: UriProps) {