Handle errors

This commit is contained in:
Natsumi
2024-10-07 20:09:30 +13:00
parent d16928f6de
commit d16d8399ca
2 changed files with 39 additions and 21 deletions

View File

@@ -70,6 +70,7 @@ namespace VRCX
if (hexString.Length != 32) if (hexString.Length != 32)
return 0; // it's cooked return 0; // it's cooked
try {
var versionHexString = hexString.Substring(16, 8); // 16..24 var versionHexString = hexString.Substring(16, 8); // 16..24
var variantVersionHexString = hexString.Substring(24, 8); // 24..32 var variantVersionHexString = hexString.Substring(24, 8); // 24..32
var versionBytes = new byte[4]; var versionBytes = new byte[4];
@@ -83,9 +84,14 @@ namespace VRCX
} }
var version = BitConverter.ToInt32(versionBytes, 0); var version = BitConverter.ToInt32(versionBytes, 0);
var variantVersion = BitConverter.ToInt32(variantVersionBytes, 0); var variantVersion = BitConverter.ToInt32(variantVersionBytes, 0);
return version + variantVersion; return version + variantVersion;
} }
catch (Exception ex)
{
logger.Error($"Failed to convert hex to decimal: {hexString} {ex}");
return 0; // it's cooked
}
}
public string GetVRChatCacheLocation() public string GetVRChatCacheLocation()
{ {

View File

@@ -2906,10 +2906,13 @@ speechSynthesis.getVoices();
try { try {
var args = await this.getFriends(params); var args = await this.getFriends(params);
friends = friends.concat(args.json); friends = friends.concat(args.json);
params.offset += 50;
break; break;
} catch (err) { } catch (err) {
console.error(err); console.error(err);
if (err?.message?.includes('Not Found')) {
console.error('Awful workaround for awful VRC API bug');
break;
}
if (j === 9) { if (j === 9) {
throw err; throw err;
} }
@@ -2918,6 +2921,7 @@ speechSynthesis.getVoices();
}); });
} }
} }
params.offset += 50;
} }
return friends; return friends;
}; };
@@ -2944,10 +2948,13 @@ speechSynthesis.getVoices();
try { try {
var args = await this.getFriends(params); var args = await this.getFriends(params);
friends = friends.concat(args.json); friends = friends.concat(args.json);
params.offset += 50;
break; break;
} catch (err) { } catch (err) {
console.error(err); console.error(err);
if (err?.message?.includes('Not Found')) {
console.error('Awful workaround for awful VRC API bug');
break;
}
if (j === 9) { if (j === 9) {
throw err; throw err;
} }
@@ -2955,6 +2962,7 @@ speechSynthesis.getVoices();
workerTimers.setTimeout(resolve, 5000); workerTimers.setTimeout(resolve, 5000);
}); });
} }
params.offset += 50;
} }
} }
return friends; return friends;
@@ -5444,9 +5452,11 @@ speechSynthesis.getVoices();
} }
try { try {
const params = new URLSearchParams(new URL(url).search); const params = new URLSearchParams(new URL(url).search);
let version = params.get('v'); const version = params.get('v');
if (version) return version; if (version) {
return '0' return version;
}
return '0';
} catch { } catch {
return '0'; return '0';
} }
@@ -9174,7 +9184,9 @@ speechSynthesis.getVoices();
console.error(err); console.error(err);
}); });
} }
await API.refreshFriends(); await API.refreshFriends().catch((err) => {
console.error(err);
});
API.reconnectWebSocket(); API.reconnectWebSocket();
}; };