[Plugins] Properly handle errors in UI
This commit is contained in:
parent
a039d183b7
commit
77dd4503b7
2 changed files with 12 additions and 4 deletions
|
@ -100,7 +100,7 @@ export function stopPlugin(id: string, disable = true) {
|
||||||
if (!pluginRet) throw new Error("Attempted to stop a non-started plugin");
|
if (!pluginRet) throw new Error("Attempted to stop a non-started plugin");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadedPlugins[plugin.id]?.onUnload?.();
|
pluginRet.onUnload?.();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logger.error(`Plugin ${plugin.id} errored whilst unloading`, e);
|
logger.error(`Plugin ${plugin.id} errored whilst unloading`, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,11 @@ export default function PluginCard({ plugin }: PluginCardProps) {
|
||||||
style={RN.Platform.OS === "android" && { marginVertical: -15 }}
|
style={RN.Platform.OS === "android" && { marginVertical: -15 }}
|
||||||
value={plugin.enabled}
|
value={plugin.enabled}
|
||||||
onValueChange={(v: boolean) => {
|
onValueChange={(v: boolean) => {
|
||||||
|
try {
|
||||||
if (v) startPlugin(plugin.id); else stopPlugin(plugin.id);
|
if (v) startPlugin(plugin.id); else stopPlugin(plugin.id);
|
||||||
|
} catch (e) {
|
||||||
|
showToast((e as Error).message, getAssetIDByName("Small"));
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@ -88,8 +92,12 @@ export default function PluginCard({ plugin }: PluginCardProps) {
|
||||||
cancelText: "Cancel",
|
cancelText: "Cancel",
|
||||||
confirmColor: "red",
|
confirmColor: "red",
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
|
try {
|
||||||
removePlugin(plugin.id);
|
removePlugin(plugin.id);
|
||||||
setRemoved(true);
|
setRemoved(true);
|
||||||
|
} catch (e) {
|
||||||
|
showToast((e as Error).message, getAssetIDByName("Small"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue