Archived
Type caught errors as unknown in the frontend
Replace `catch (e: any)` with `catch (e)` and read the message through a new errorMessage() helper. ApiError.data gets a real type, and useDismissingState's setter keeps one identity across renders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,10 +57,12 @@ export function useQRScanner(videoEl: HTMLVideoElement | null, opts: UseQRScanne
|
||||
cancelRef.current = () => {
|
||||
cancelled = true;
|
||||
};
|
||||
} catch (err: any) {
|
||||
if (err?.name === "NotAllowedError") {
|
||||
} catch (err) {
|
||||
// getUserMedia rejects with a DOMException whose `name` says why.
|
||||
const name = (err as { name?: string } | null)?.name;
|
||||
if (name === "NotAllowedError") {
|
||||
setPermissionError("Camera permission denied. Please enable camera access.");
|
||||
} else if (err?.name === "NotFoundError") {
|
||||
} else if (name === "NotFoundError") {
|
||||
setPermissionError("No suitable camera found. Try a device with a back camera.");
|
||||
} else {
|
||||
setPermissionError("Unable to access camera.");
|
||||
|
||||
Reference in New Issue
Block a user