From cad010482b9c29375980e442c34d8d0107296a2f Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 4 May 2022 20:46:12 +0800 Subject: [PATCH] ui: support window.captureException --- packages/ui-default/components/zipDownloader/index.js | 2 ++ packages/ui-default/hydro.ts | 1 + packages/ui-default/package.json | 2 +- packages/ui-default/pages/home_files.page.js | 1 + packages/ui-default/pages/problem_files.page.js | 2 ++ 5 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/ui-default/components/zipDownloader/index.js b/packages/ui-default/components/zipDownloader/index.js index 56ea2f88d..eb3c3e183 100644 --- a/packages/ui-default/components/zipDownloader/index.js +++ b/packages/ui-default/components/zipDownloader/index.js @@ -51,6 +51,7 @@ export default async function download(filename, targets) { stream, }; } catch (e) { + window.captureException?.(e); stopDownload(); Notification.error(i18n('Download Error', [target.filename, e.toString()])); } @@ -144,6 +145,7 @@ export async function downloadProblemSet(pids, name = 'Export') { } await download(`${name}.zip`, targets); } catch (e) { + window.captureException?.(e); Notification.error(`${e.message} ${e.params?.[0]}`); } } diff --git a/packages/ui-default/hydro.ts b/packages/ui-default/hydro.ts index 848db2ab4..20d45eaae 100644 --- a/packages/ui-default/hydro.ts +++ b/packages/ui-default/hydro.ts @@ -64,6 +64,7 @@ async function load() { try { await func(currentPageName, loadPage(1, type)); } catch (e) { + (window as any).captureException?.(e); Notification.warn(`Failed to call '${type}Loading' of ${page.name}`); console.error(`Failed to call '${type}Loading' of ${page.name}\n${e.stack}`); console.error(e); diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index a879f8f0a..882932c39 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.35.1", + "version": "4.35.2", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", diff --git a/packages/ui-default/pages/home_files.page.js b/packages/ui-default/pages/home_files.page.js index 4b8a816cd..1aca098df 100644 --- a/packages/ui-default/pages/home_files.page.js +++ b/packages/ui-default/pages/home_files.page.js @@ -88,6 +88,7 @@ async function handleClickUpload(files) { Notification.success(i18n('File uploaded successfully.')); await pjax.request({ push: false }); } catch (e) { + window.captureException?.(e); console.error(e); Notification.error(i18n('File upload failed: {0}', e.toString())); } finally { diff --git a/packages/ui-default/pages/problem_files.page.js b/packages/ui-default/pages/problem_files.page.js index 4692c389f..1b4e08311 100644 --- a/packages/ui-default/pages/problem_files.page.js +++ b/packages/ui-default/pages/problem_files.page.js @@ -100,6 +100,7 @@ const page = new NamedPage('problem_files', () => { Notification.success(i18n('File uploaded successfully.')); await pjax.request({ push: false }); } catch (e) { + window.captureException?.(e); console.error(e); Notification.error(i18n('File upload failed: {0}', e.toString())); } finally { @@ -238,6 +239,7 @@ const page = new NamedPage('problem_files', () => { const res = await request.get(link); content = await request.get(res.url, undefined, { dataType: 'text' }); } catch (e) { + window.captureException?.(e); Notification.error(i18n('Failed to load file: {0}', e.message)); throw e; }