From d3d9d6c012520a36a4deb1fdc7e373a166ffb2e3 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 24 Mar 2021 08:53:46 +0100 Subject: [PATCH] try/catch --- .../src/app/ui/landing-page/landing-page.js | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 85e7f61de5..28e7a88891 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -298,24 +298,30 @@ export class LandingPage extends ViewPlugin { } const downloadFiles = async () => { - const fileProviders = globalRegistry.get('fileproviders').api - const json = await fileProviders.browser.copyFolderToJson('/') + try { + const fileProviders = globalRegistry.get('fileproviders').api + const json = await fileProviders.browser.copyFolderToJson('/') + const blob = new Blob([ JSON.stringify(json, null, '\t') ], { type: 'text/plain;charset=utf-8' }) const blob = new Blob([ JSON.stringify(json, null, '\t') ], { type: 'text/plain;charset=utf-8' }) - const node = document.createElement('a') - node.download = 'remix.json' - node.rel = 'noopener' - node.href = URL.createObjectURL(blob) - setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s - setTimeout(function () { - try { - node.dispatchEvent(new MouseEvent('click')) - } catch (e) { - var evt = document.createEvent('MouseEvents') - evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, - 20, false, false, false, false, 0, null) - node.dispatchEvent(evt) - } - }, 0) // 40s + const blob = new Blob([ JSON.stringify(json, null, '\t') ], { type: 'text/plain;charset=utf-8' }) + const node = document.createElement('a') + node.download = 'remix.json' + node.rel = 'noopener' + node.href = URL.createObjectURL(blob) + setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s + setTimeout(function () { + try { + node.dispatchEvent(new MouseEvent('click')) + } catch (e) { + var evt = document.createEvent('MouseEvents') + evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, + 20, false, false, false, false, 0, null) + node.dispatchEvent(evt) + } + }, 0) // 40s + } catch (e) { + tooltip(e.message) + } } const uploadFile = (target) => {