diff --git a/packages/ui-default/pages/problem_config.page.tsx b/packages/ui-default/pages/problem_config.page.tsx index ba8ab02d2..32771fb24 100644 --- a/packages/ui-default/pages/problem_config.page.tsx +++ b/packages/ui-default/pages/problem_config.page.tsx @@ -82,10 +82,21 @@ const page = new NamedPage('problem_config', () => { async function handleClickDownloadAll() { const files = reduxStore.getState().testdata.map((i) => i.name); - const { links, pdoc } = await request.post('./files', { operation: 'get_links', files, type: 'testdata' }); - const targets: { filename: string, url: string }[] = []; - for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] }); - await download(`${pdoc.docId} ${pdoc.title}.zip`, targets); + try { + const { links, pdoc } = await request.post('./files', { operation: 'get_links', files, type: 'testdata' }); + const targets: { filename: string, url: string }[] = []; + for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] }); + await download(`${pdoc.docId} ${pdoc.title}.zip`, targets); + } catch (error) { + const err = error as { message?: string; params?: unknown }; + const params = Array.isArray(err.params) + ? err.params + : err.params + ? [String(err.params)] + : []; + const message = [err.message, ...params].filter(Boolean).join(' ') || i18n('Unknown error'); + Notification.error(message); + } } async function uploadConfig(config: object) { diff --git a/packages/ui-default/pages/problem_files.page.tsx b/packages/ui-default/pages/problem_files.page.tsx index e73f44761..706c89cc1 100644 --- a/packages/ui-default/pages/problem_files.page.tsx +++ b/packages/ui-default/pages/problem_files.page.tsx @@ -26,10 +26,21 @@ const page = new NamedPage('problem_files', () => { const type = $(ev.currentTarget).closest('[data-type]').attr('data-type'); const files = ensureAndGetSelectedFiles(type); if (files === null) return; - const { links, pdoc } = await request.post('', { operation: 'get_links', files, type }); - const targets = []; - for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] }); - await download(`${pdoc.docId} ${pdoc.title} ${type}.zip`, targets); + try { + const { links, pdoc } = await request.post('', { operation: 'get_links', files, type }); + const targets = []; + for (const filename of Object.keys(links)) targets.push({ filename, url: links[filename] }); + await download(`${pdoc.docId} ${pdoc.title} ${type}.zip`, targets); + } catch (error) { + const err = error as { message?: string; params?: unknown }; + const params = Array.isArray(err.params) + ? err.params + : err.params + ? [String(err.params)] + : []; + const message = [err.message, ...params].filter(Boolean).join(' ') || i18n('Unknown error'); + Notification.error(message); + } } async function handleGenerateTestdata(ev) {