@samitouri / QOSami-HFS / commits / bde71f62

plugins: better errors

Massimo Melina committed Jun 29, 2024 at 10:26 UTC bde71f622904afdaee3025e8f7439d6fcc3bb0fe
2 files changed +4 -1
admin/src/mui.ts
+1
@@ -281,6 +281,7 @@ async function ip2countryBatch(ips: string[]) {
281 export function hTooltip(title: ReactNode, ariaLabel: string | undefined, children: ReactElement, props?: Omit<TooltipProps, 'title' | 'children'> & { key?: any }) {
282 return h(Tooltip, { title, children,
283 ...ariaLabel === '' ? { 'aria-hidden': true } : { 'aria-label': ariaLabel },
284 + componentsProps: { popper: { sx: { whiteSpace: 'pre-wrap', ...props?.sx } } },
285 ...props
286 })
287 }
\ No newline at end of file
src/plugins.ts
+3 -1
@@ -470,7 +470,9 @@ function watchPlugin(id: string, path: string) {
470 events.emit('pluginStarted:'+id)
471 } catch (e: any) {
472 await markItAvailable()
473 - e = e.message || String(e)
473 + const parsed = e.stack?.split('\n\n') // this form is used by syntax-errors inside the plugin, which is useful to show
474 + const where = parsed?.length > 1 ? `\n${parsed[0]}` : ''
475 + e = e.message + where || String(e)
476 console.log(`plugin error: ${id}:`, e)
477 setError(id, e)
478 }