Skip to content

Commit

Permalink
Merge pull request #3113 from digitalfabrik/3112-tts-stop
Browse files Browse the repository at this point in the history
3112: Prevent unnecessary tts stop
  • Loading branch information
steffenkleinle authored Feb 21, 2025
2 parents b8a6052 + 3e96eeb commit 9105751
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions native/src/utils/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,26 @@ export const log = (message: string, level: SeverityLevel = 'debug'): void => {
}
}

export const reportError = (err: unknown): void => {
if (!(err instanceof NotFoundError) && !(err instanceof FetchError) && sentryEnabled()) {
// Report important errors if sentry is enabled (and skip e.g. errors because of no invalid internet connection)
Sentry.captureException(err)
// https://github.com/digitalfabrik/integreat-app/issues/1759
const storeLastUpdate = 'cannot store last update for unused city'
// https://github.com/digitalfabrik/integreat-app/issues/3112
const noTtsEngineInstalled = 'No TTS engine installed'
const expectedErrors = [storeLastUpdate, noTtsEngineInstalled]

export const reportError = (error: unknown): void => {
const isNotFoundError = error instanceof NotFoundError
const isNoInternetError = error instanceof FetchError
const isExpectedError = error instanceof Error && expectedErrors.some(message => error.message.includes(message))
const ignoreError = isNotFoundError || isNoInternetError || isExpectedError

if (ignoreError) {
return
}

if (sentryEnabled()) {
Sentry.captureException(error)
}
if (developerFriendly()) {
console.error(err)
console.error(error)
}
}

0 comments on commit 9105751

Please sign in to comment.