MCPcopy Create free account
hub / github.com/adobe/react-spectrum / mapMediaError

Function mapMediaError

packages/@react-spectrum/ai/src/useVoiceInput.ts:110–119  ·  view source on GitHub ↗
(err: unknown)

Source from the content-addressed store, hash-verified

108
109/** Maps a getUserMedia rejection to a normalised error code. */
110const mapMediaError = (err: unknown): VoiceInputErrorCode => {
111 const name = err instanceof DOMException ? err.name : '';
112 if (name === 'NotAllowedError' || name === 'SecurityError') {
113 return 'not-allowed';
114 }
115 if (name === 'NotFoundError' || name === 'NotReadableError') {
116 return 'audio-capture';
117 }
118 return 'unknown';
119};
120
121/**
122 * Requests microphone access so the browser permission prompt reliably opens and

Callers 1

requestMicrophoneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected