Merge pull request #119 from Flow-Works/dev
[✨] Added better error handling at boot
This commit is contained in:
commit
bd846cd028
1 changed files with 12 additions and 8 deletions
|
|
@ -31,6 +31,8 @@ class Flow {
|
|||
window.fs.promises.readdir('/Applications').then((list) => {
|
||||
list.forEach((file) => {
|
||||
window.fs.promises.readFile('/Applications/' + file).then(content => {
|
||||
if (!content.toString().endsWith('.js')) return
|
||||
if (content.toString() === '') return
|
||||
this.appList.push(`data:text/javascript;base64,${btoa(content.toString())}`)
|
||||
}).catch((e) => console.error(e))
|
||||
})
|
||||
|
|
@ -55,16 +57,18 @@ class Flow {
|
|||
for (const appPath of this.appList) {
|
||||
window.preloader.setStatus(`importing appstore apps\n${appPath}`)
|
||||
|
||||
const { default: ImportedApp } = await import(/* @vite-ignore */ appPath).catch(async (e: Error) => {
|
||||
try {
|
||||
const { default: ImportedApp } = await import(appPath)
|
||||
const app = new ImportedApp()
|
||||
app.builtin = false
|
||||
app.meta.icon = app.meta.icon ?? nullIcon
|
||||
|
||||
this.addApp(app)
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
await window.preloader.setError('apps')
|
||||
window.preloader.setStatus(`unable to import ${appPath}\n${e.name}: ${e.message}`)
|
||||
})
|
||||
const app = new ImportedApp()
|
||||
app.builtin = false
|
||||
app.meta.icon = app.meta.icon ?? nullIcon
|
||||
|
||||
this.addApp(app)
|
||||
window.preloader.setStatus(`unable to import ${appPath}\n${(e as Error).name}: ${(e as Error).message}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue