From e26da47efa726abfea83c3a15f5de47636c72d07 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Wed, 4 Sep 2024 15:32:10 +0200 Subject: [PATCH] fix(frontend): Don't crash on color retrieval error (#24780) --- frontend/src/lib/colors.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/colors.ts b/frontend/src/lib/colors.ts index 1413b241800a0..cc9530b5bc524 100644 --- a/frontend/src/lib/colors.ts +++ b/frontend/src/lib/colors.ts @@ -1,3 +1,5 @@ +import { captureException } from '@sentry/react' + import { LifecycleToggle } from '~/types' import { LemonTagType } from './lemon-ui/LemonTag' @@ -39,7 +41,9 @@ export const tagColors: LemonTagType[] = [ export function getColorVar(variable: string): string { const colorValue = getComputedStyle(document.body).getPropertyValue('--' + variable) if (!colorValue) { - throw new Error(`Couldn't find color variable --${variable}`) + captureException(new Error(`Couldn't find color variable --${variable}`)) + // Fall back to black or white depending on the theme + return document.body.getAttribute('theme') === 'light' ? '#000' : '#fff' } return colorValue.trim() }