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

Function mapErrorCode

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

Source from the content-addressed store, hash-verified

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

Callers 1

createRecognizerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected