admin/plugins: better error when plugins fail to start
Massimo Melina committed
Oct 6, 2023 at 18:15 UTC
d90a49de0221f00af1501232e78b1065fb6ba1d4
1 file changed
+9
-3
admin/src/InstalledPlugins.ts
+9
-3
@@ -6,7 +6,7 @@ import { Box, Link, Tooltip } from '@mui/material'
6
import { DataTable } from './DataTable'
7
import { Delete, Error as ErrorIcon, PlayCircle, Settings, StopCircle, Upgrade } from '@mui/icons-material'
8
import { IconBtn, prefix, with_, xlate } from './misc'
9
-import { formDialog, toast } from './dialog'
9
+import { alertDialog, formDialog, toast } from './dialog'
10
import _ from 'lodash'
11
import { BoolField, Field, MultiSelectField, NumberField, SelectField, StringField } from '@hfs/mui-grid-form'
12
import { ArrayField } from './ArrayField'
@@ -158,6 +158,12 @@ const type2comp = {
158
}
159
160
export async function startPlugin(id: string) {
161
- await apiCall('start_plugin', { id })
162
- toast("Plugin started", h(PlayCircle, { color: 'success' }))
161
+ try {
162
+ await apiCall('start_plugin', { id })
163
+ toast("Plugin started", h(PlayCircle, { color: 'success' }))
164
+ return true
165
+ }
166
+ catch(e: any) {
167
+ alertDialog(`Plugin ${id} didn't start, with error: ${String(e?.message || e)}`, 'error')
168
+ }
169
}