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

Function mapErrorCode

packages/@react-spectrum/ai/src/useVoiceInput.ts:85–105  ·  view source on GitHub ↗
(error: string)

Source from the content-addressed store, hash-verified

83
84/** Maps a raw recognition error to a normalised code, or `null` to ignore it. */
85const mapErrorCode = (error: string): VoiceInputErrorCode | null => {
86 switch (error) {
87 case 'aborted':
88 return null;
89 case 'not-allowed':
90 case 'service-not-allowed':
91 return 'not-allowed';
92 case 'network':
93 return 'network';
94 case 'no-speech':
95 return 'no-speech';
96 case 'audio-capture':
97 return 'audio-capture';
98 case 'language-not-supported':
99 return 'language-not-supported';
100 case 'phrases-not-supported':
101 return 'phrases-not-supported';
102 default:
103 return 'unknown';
104 }
105};
106
107/** Maps a getUserMedia rejection to a normalised error code. */
108const mapMediaError = (err: unknown): VoiceInputErrorCode => {

Callers 1

createRecognizerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected