Error Handling
Handle errors gracefully and provide better user experience with comprehensive error codes and messages.
const recorder = sdk.createRecorder({
onError: (error) => {
switch (error.code) {
case 'MICROPHONE_ACCESS_DENIED':
alert('Please allow microphone access');
break;
case 'RECORDING_NOT_SUPPORTED':
alert('Recording not supported in this browser');
break;
case 'RECORDING_TOO_LONG':
alert('Voice note too long. Maximum 60 seconds');
break;
case 'NETWORK_ERROR':
alert('Network error. Please check your connection');
break;
case 'AUTHENTICATION_FAILED':
alert('Session expired. Refresh and try again');
break;
default:
alert(`Error: ${error.userMessage || error.message}`);
}
}
});
Error Codes
| Code | Description |
|---|---|
MICROPHONE_ACCESS_DENIED | Microphone access denied |
RECORDING_NOT_SUPPORTED | MediaRecorder not supported or no compatible format |
RECORDING_TOO_LONG | Voice note exceeded max duration |
NETWORK_ERROR | Upload failed due to network |
AUTHENTICATION_FAILED | Invalid or expired token |