Skip to content

Commit 7afd236

Browse files
Fix for SvgUri and SvgCssUri crashing on non-existing svg files (software-mansion#1503)
Fix for interpreting an HTML error response as svg data, and then crash when this cannot be parsed as well formed XML
1 parent 650275f commit 7afd236

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/xml.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ export function SvgXml(props: XmlProps) {
124124

125125
export async function fetchText(uri: string) {
126126
const response = await fetch(uri);
127-
return await response.text();
127+
if (response.ok) {
128+
return await response.text();
129+
}
130+
throw new Error(`Fetching ${uri} failed with status ${response.status}`);
128131
}
129132

130133
export function SvgUri(props: UriProps) {

0 commit comments

Comments
 (0)