Added error handling

This commit is contained in:
nutty
2026-07-03 01:03:21 +10:00
parent 3ac06ed9c3
commit 64793d2114
+31
View File
@@ -48,6 +48,7 @@ const hideAnimation = urlParams.get('hideAnimation') || 'slide-out-bottom';
let smtcBridgePopup = null;
let versionCheckPopup = null;
let errorPopup = null;
let skipVersionCheck = false;
let CurrentPlaybackStatus;
let CurrentSongKey;
@@ -156,6 +157,15 @@ async function FetchMedia() {
// Remove the SMTC Bridge popup if it's on screen
CloseSMTCBridgePopup();
// Check for errors in the response
if (data.error) {
ShowErrorPopup(data.error);
return;
}
else {
CloseErrorPopup();
}
// Check the SMTC Bridge version
CheckSMTCBridgeVersion(data.app_version);
@@ -249,6 +259,27 @@ function ShowSMTCBridgeUpdateAvailablePopup(installedVersion) {
}, 10000);
}
function ShowErrorPopup(errorMessage) {
const newPopup = SplashscreenPopup(
'/.common/resources/smtc-bridge-icon.png',
'SMTC Bridge Error',
`I'm a shit programmer and I fucked something up.`,
`Error: ${errorMessage}`,
'linear-gradient(0deg, #1b0005 0%, #4f000d 100%)'
);
if (newPopup) {
errorPopup = newPopup;
}
}
function CloseErrorPopup() {
if (errorPopup) {
errorPopup.close();
errorPopup = null;
}
}
function CloseSMTCBridgePopup()
{
if (smtcBridgePopup) {