Skip to content

Commit

Permalink
Report speech synthesis error only once
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Nov 30, 2023
1 parent 1b3734e commit 6bc77c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/lib/rollbar/rollbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,16 @@ export const reportHandledError = (description: string, e?: any, info?: any) =>
// @ts-ignore
Rollbar.error(description, e, info);
};

let reported = false;

export const reportHandledErrorOnce = (description: string, e?: any, info?: any) => {
if (reported) {
return;
}
reported = true;
console.error(e);
// @ts-ignore
Rollbar.error(description, e, info);
};

7 changes: 5 additions & 2 deletions src/lib/voice-playback/speak.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { reportHandledError } from "../rollbar/rollbar.tsx";
import {
reportHandledError,

Check failure on line 2 in src/lib/voice-playback/speak.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

'reportHandledError' is defined but never used
reportHandledErrorOnce
} from "../rollbar/rollbar.tsx";

export enum SpeakLanguageEnum {
AmericanEnglish = "en-US",
Expand Down Expand Up @@ -48,7 +51,7 @@ export const speak = (text: string, language: SpeakLanguageEnum) => {
typeof SpeechSynthesisUtterance !== "undefined";

if (!isSpeechSynthesisSupported) {
reportHandledError(
reportHandledErrorOnce(
`Speech synthesis is not supported in this browser. Browser info: ${navigator.userAgent}`,
);
return;
Expand Down

0 comments on commit 6bc77c9

Please sign in to comment.