From cc4b0ce8ca30960925e2da4537d44aeeaaf8474c Mon Sep 17 00:00:00 2001 From: Mariotaku Date: Thu, 22 Jun 2023 14:49:43 +0900 Subject: [PATCH] don't send any handled error --- src/app/app.component.ts | 2 +- src/app/core/services/backend-client.ts | 8 +++----- src/main.ts | 12 +++++++++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e8e8b14d..e4942e67 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -30,7 +30,7 @@ export class AppComponent { if (remoteVer.compare(curVer) > 0) { await this.notifyUpdate(info, remoteVer); } - }); + }).catch(noop); deviceManager.load(); } diff --git a/src/app/core/services/backend-client.ts b/src/app/core/services/backend-client.ts index 60fe89dd..2b88299a 100644 --- a/src/app/core/services/backend-client.ts +++ b/src/app/core/services/backend-client.ts @@ -13,14 +13,12 @@ export abstract class BackendClient { tauri.invoke(cmd, args) .then(result => { console.debug('invoke', `${this.category}/${method}`, 'result', result); - return result; + this.zone.run(() => resolve(result as any)); }) .catch(reason => { console.warn('invoke', `${this.category}/${method}`, 'error', reason); - throw new BackendError(reason); - }) - .then(result => this.zone.run(() => resolve(result as any))) - .catch(reason => this.zone.run(() => reject(reason))); + this.zone.run(() => reject(new BackendError(reason))); + }); }); } diff --git a/src/main.ts b/src/main.ts index d2f077b4..95abad55 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import {AppConfig} from './environments/environment'; import ReleaseInfo from './release.json'; import * as Sentry from "@sentry/angular-ivy"; import {Breadcrumb, defaultStackParser} from "@sentry/angular-ivy"; +import {remove} from "lodash"; Sentry.init({ dsn: "https://93c623f5a47940f0b7bac7d0d5f6a91f@o4504977150377984.ingest.sentry.io/4504978685689856", @@ -15,7 +16,7 @@ Sentry.init({ routingInstrumentation: Sentry.routingInstrumentation, }) ], - enabled: !!ReleaseInfo.version, + enabled: true, environment: AppConfig.environment, release: ReleaseInfo.version || 'local', stackParser: (stack: string, skipFirst?: number) => { @@ -26,6 +27,15 @@ Sentry.init({ beforeBreadcrumb: (breadcrumb: Breadcrumb) => { return breadcrumb.level !== 'debug' ? breadcrumb : null; }, + beforeSend: (event) => { + if (event.exception?.values) { + const filtered = remove(event.exception?.values, e => e.mechanism?.handled !== true); + if (filtered.length === 0) { + return null; + } + } + return event; + }, // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. // We recommend adjusting this value in production