Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

🐛(frontend) normalize thrown values into proper Error instances

lebaudantoine23bb3c39d0c0
diff --git a/src/frontend/src/features/rooms/components/Conference.tsx b/src/frontend/src/features/rooms/components/Conference.tsx
index 1e6d1f25..18c576d9 100644
--- a/src/frontend/src/features/rooms/components/Conference.tsx
+++ b/src/frontend/src/features/rooms/components/Conference.tsx
@@ -37,6 +37,7 @@ import { notifyAutoMutedOnJoin } from '@/features/notifications/utils'
import { useSnapshot } from 'valtio'
import { userPreferencesStore } from '@/stores/userPreferences'
import { userStore } from '@/stores/user'
+import { asError } from '../utils/error'
export const Conference = ({
roomId,
@@ -235,7 +236,7 @@ export const Conference = ({
backgroundColor: 'primaryDark.50 !important',
})}
onError={(e) => {
- posthog.captureException(e)
+ posthog.captureException(asError(e))
}}
onConnected={async () => {
if (!apiConfig) return
diff --git a/src/frontend/src/features/rooms/utils/error.ts b/src/frontend/src/features/rooms/utils/error.ts
new file mode 100644
index 00000000..c7556b39
--- /dev/null
+++ b/src/frontend/src/features/rooms/utils/error.ts
@@ -0,0 +1,9 @@
+export const asError = (value: unknown): Error => {
+ if (value instanceof Error) return value
+ if (value instanceof Event) {
+ return new Error(
+ `Unhandled event "${value.type}" from ${value.target?.constructor.name ?? 'unknown'}`
+ )
+ }
+ return new Error(String(value))
+}