fix(audio): handle NotAllowedError in skipCheck:true scenarios

In scenarios where the join audio flow skips echo test, NotAllowedError
(and any other errors) are all being mashed together under a generic
MEDIA_ERROR object.

Properly handle specific errors in audio-manager so they're correctly
render in the audio modal help screen.
This commit is contained in:
prlanzarin 2024-04-09 15:17:18 -03:00
parent 501d627392
commit 68f66a1fbb
3 changed files with 24 additions and 14 deletions

View File

@ -359,20 +359,21 @@ class AudioModal extends Component {
} }
handleJoinMicrophoneError(err) { handleJoinMicrophoneError(err) {
const { type } = err; const { type, errCode, errMessage } = err;
switch (type) { switch (type) {
case 'MEDIA_ERROR': case 'MEDIA_ERROR':
this.setState({ this.setState({
content: 'help', content: 'help',
errCode: 0, errCode,
errMessage: type, errMessage,
disableActions: false, disableActions: false,
}); });
break; break;
case 'CONNECTION_ERROR': case 'CONNECTION_ERROR':
default: default:
this.setState({ this.setState({
errCode: 0, errCode,
errMessage: type, errMessage: type,
disableActions: false, disableActions: false,
}); });
@ -533,7 +534,7 @@ class AudioModal extends Component {
this.setState({ this.setState({
content: 'help', content: 'help',
errCode, errCode,
errMessage: error?.name || 'GUMFailure', errMessage: error?.name || 'NotAllowedError',
disableActions: false, disableActions: false,
}); });
}; };

View File

@ -1,7 +1,9 @@
const MIC_ERROR = { const MIC_ERROR = {
UNKNOWN: 0,
NO_SSL: 9, NO_SSL: 9,
MAC_OS_BLOCK: 8, MAC_OS_BLOCK: 8,
NO_PERMISSION: 7, NO_PERMISSION: 7,
DEVICE_NOT_FOUND: 6,
}; };
export default { MIC_ERROR }; export default { MIC_ERROR };

View File

@ -333,14 +333,16 @@ class AudioManager {
return this.bridge return this.bridge
.joinAudio(callOptions, callStateCallback.bind(this)) .joinAudio(callOptions, callStateCallback.bind(this))
.catch((error) => { .catch((error) => {
const { name } = error; const { name, message } = error;
const errorPayload = {
if (!name) { type: 'MEDIA_ERROR',
throw error; errMessage: message || 'MEDIA_ERROR',
} errCode: AudioErrors.MIC_ERROR.UNKNOWN,
};
switch (name) { switch (name) {
case 'NotAllowedError': case 'NotAllowedError':
errorPayload.errCode = AudioErrors.MIC_ERROR.NO_PERMISSION;
logger.error( logger.error(
{ {
logCode: 'audiomanager_error_getting_device', logCode: 'audiomanager_error_getting_device',
@ -353,6 +355,7 @@ class AudioManager {
); );
break; break;
case 'NotFoundError': case 'NotFoundError':
errorPayload.errCode = AudioErrors.MIC_ERROR.DEVICE_NOT_FOUND;
logger.error( logger.error(
{ {
logCode: 'audiomanager_error_device_not_found', logCode: 'audiomanager_error_device_not_found',
@ -364,17 +367,21 @@ class AudioManager {
`Error getting microphone - {${error.name}: ${error.message}}` `Error getting microphone - {${error.name}: ${error.message}}`
); );
break; break;
default: default:
logger.error({
logCode: 'audiomanager_error_unknown',
extraInfo: {
errorName: error.name,
errorMessage: error.message,
},
}, `Error getting microphone - {${name}: ${message}}`);
break; break;
} }
this.isConnecting = false; this.isConnecting = false;
this.isWaitingPermissions = false; this.isWaitingPermissions = false;
throw { throw errorPayload;
type: 'MEDIA_ERROR',
};
}); });
} }