Skip to content

Commit a483559

Browse files
fix: capture all compatability errors
1 parent 66fc6c7 commit a483559

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/pages/splashscreen.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
Progress,
1919
Spinner,
2020
} from "@chakra-ui/react";
21-
import { CheckIcon, CloseIcon } from "@chakra-ui/icons";
21+
import { CheckIcon, CloseIcon, InfoIcon } from "@chakra-ui/icons";
2222
import { Button, Spacer } from "@freecodecamp/ui";
2323
import { createRoute, useNavigate } from "@tanstack/react-router";
2424
import { captureException } from "@sentry/react";
@@ -117,13 +117,7 @@ export function Splashscreen() {
117117
const compatibilityCheckQuery = useQuery({
118118
queryKey: ["compatabilityCheck"],
119119
enabled: downloadAndInstallQuery.isSuccess || !update,
120-
queryFn: async () => {
121-
const compatibilityError = await checkDeviceCompatibility();
122-
if (compatibilityError) {
123-
throw compatibilityError;
124-
}
125-
return null;
126-
},
120+
queryFn: checkDeviceCompatibility,
127121
retry: false,
128122
refetchOnWindowFocus: false,
129123
});
@@ -194,7 +188,7 @@ export function Splashscreen() {
194188
App update found
195189
</ListItem>
196190
<ListItem fontWeight={900} display="flex" alignItems="center">
197-
<ListIcon as={Spinner} color="blue.500" marginTop="2px" />
191+
<ListIcon as={InfoIcon} color="blue.500" marginTop="2px" />
198192
Download update (version {update.version})?
199193
</ListItem>
200194
<Button block={true} onClick={() => downloadAndInstallQuery.mutate()}>
@@ -444,7 +438,11 @@ async function checkDeviceCompatibility() {
444438
await delayForTesting(1000);
445439
}
446440
const compatError = await updateDeviceList();
447-
return compatError;
441+
if (compatError) {
442+
captureException(compatError);
443+
throw compatError;
444+
}
445+
return null;
448446
}
449447

450448
// Check devices and permissions
@@ -456,14 +454,15 @@ async function updateDeviceList() {
456454
const atLeastOneAudioOutput = devices.some((d) => d.kind === "audiooutput");
457455
if (!atLeastOneAudioOutput) {
458456
return new Error(
459-
"No audio output device found. Please check your device settings."
457+
`No audio output device found. Please check your device settings. Ensure that at least one audio output device (e.g., speakers or headphones) is connected and recognized by your system. Found media devices: ${devices.map((d) => d.label).join(", ")}`
460458
);
461459
}
462460

463461
return null;
464462
} catch (e) {
465-
captureException(e);
466-
return new Error("There is an error accessing an audio playback device.");
463+
return new Error(
464+
`There is an error accessing an audio playback device. ${String(e)}`
465+
);
467466
}
468467
}
469468

0 commit comments

Comments
 (0)