feat: Add hardened error handling and retries (#2451)

- Closes #1830
 - Closes #2099
This commit is contained in:
Dermot Duffy
2026-06-30 17:45:12 -07:00
committed by dermotduffy
parent 4bc787e2b7
commit 47bcce93d3
182 changed files with 7877 additions and 4043 deletions
+11 -7
View File
@@ -1,7 +1,14 @@
import { errorToConsole } from '../utils/basic';
import { localize } from '../localize/localize';
import { AdvancedCameraCardError } from '../types';
import { Timer } from '../utils/timer';
import { CardMicrophoneAPI, MicrophoneState } from './types';
export class MicrophoneNotSupportedError extends AdvancedCameraCardError {
constructor() {
super(localize('error.microphone_not_supported'));
}
}
export class MicrophoneManager {
private _api: CardMicrophoneAPI;
private _stream?: MediaStream | null;
@@ -46,9 +53,9 @@ export class MicrophoneManager {
return !!navigator.mediaDevices?.getUserMedia;
}
public async connect(): Promise<boolean> {
public async connect(): Promise<void> {
if (!this.isSupported()) {
return false;
throw new MicrophoneNotSupportedError();
}
try {
@@ -57,15 +64,12 @@ export class MicrophoneManager {
video: false,
});
} catch (e: unknown) {
errorToConsole(e as Error);
this._stream = null;
this._setState();
return false;
throw e;
}
this._setDesiredMuteOnStream();
this._setState();
return true;
}
public disconnect(): void {