Show error when not able to get the server list

This commit is contained in:
redphx
2025-06-21 18:12:58 +07:00
parent f7048a38b3
commit 88151c9426
5 changed files with 22 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ type EventCallback<T = any> = (payload: T) => void;
export type ScriptEvents = {
'xcloud.server': {
status: 'ready' | 'unavailable' | 'signed-out',
status: 'ready' | 'unavailable' | 'signed-out' | 'error',
};
'dialog.shown': {};

View File

@@ -49,7 +49,13 @@ export class XcloudInterceptor {
ip && (request as Request).headers.set('X-Forwarded-For', ip);
}
const response = await NATIVE_FETCH(request, init);
let response;
try {
response = await NATIVE_FETCH(request, init);
} catch (e) {
BxEventBus.Script.emit('xcloud.server', { status: 'error' });
return;
}
if (response.status !== 200) {
// Unsupported region
BxEventBus.Script.emit('xcloud.server', { status: 'unavailable' });