From 70b36265f532c5a08a7102e5daaf1e32c8112ffd Mon Sep 17 00:00:00 2001 From: chenxsan Date: Mon, 18 Jul 2022 21:45:55 +0800 Subject: [PATCH] fix: catch CORS error --- src/hooks/useColor.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hooks/useColor.ts b/src/hooks/useColor.ts index 6f990101520..bd8458b9d72 100644 --- a/src/hooks/useColor.ts +++ b/src/hooks/useColor.ts @@ -46,7 +46,13 @@ async function getColorFromToken(token: Token): Promise { async function getColorFromUriPath(uri: string): Promise { const formattedPath = uriToHttp(uri)[0] - const palette = await Vibrant.from(formattedPath).getPalette() + let palette + + try { + palette = await Vibrant.from(formattedPath).getPalette() + } catch (err) { + return null + } if (!palette?.Vibrant) { return null }