From 5fcd4751188ce49ccd04e710b990711ae236e180 Mon Sep 17 00:00:00 2001 From: LawnCable Date: Fri, 29 Jun 2018 00:07:56 +0200 Subject: - Some Error handeling related bugfixes --- src/main/manaplus/manaplus.ts | 7 +++++-- src/renderer/gameserver/TOSCheck.ts | 3 +++ src/renderer/gameserver/news.ts | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/manaplus/manaplus.ts b/src/main/manaplus/manaplus.ts index 9183b94..2f028b8 100644 --- a/src/main/manaplus/manaplus.ts +++ b/src/main/manaplus/manaplus.ts @@ -42,7 +42,8 @@ export namespace ManaPlus{ //params = ['-v'];// DEBUG: This option is to disable manaplus for testing (open it just for getting the version) } catch (e){ console.log(e); - Status.showError("Launch Preperation Failed", e.message, "Launch preparation failed") + Status.showError("Launch Preperation Failed (LPF_PARMS)", e.message, "Launch preparation failed"); + Status.setPlaying(false); return; } let willUpdate:boolean=false; @@ -54,7 +55,9 @@ export namespace ManaPlus{ willUpdate = (version.isNewVersion && await updateDialog(version.newestVersion)); } catch (e){ console.log(e); - Status.showError("Launch Preperation Failed", e.message, "Launch preparation failed") + Status.showError("Launch Preperation Failed (LPF_Update): This error can also mean that you are offline, \ +please check you network connection first.", e.message, "Launch preparation failed") + Status.setPlaying(false); return; } } else { diff --git a/src/renderer/gameserver/TOSCheck.ts b/src/renderer/gameserver/TOSCheck.ts index 8dc29f2..e2e4bfc 100644 --- a/src/renderer/gameserver/TOSCheck.ts +++ b/src/renderer/gameserver/TOSCheck.ts @@ -35,6 +35,9 @@ function request(url:string):Promise{ return new Promise((res, rej)=>{ var xhr = new XMLHttpRequest(); xhr.open('GET', url); + xhr.addEventListener("error", (ev)=>{ + rej(ev); + }); xhr.onload = function() { if (xhr.status === 200) { res(xhr.responseText); diff --git a/src/renderer/gameserver/news.ts b/src/renderer/gameserver/news.ts index b748777..094172c 100644 --- a/src/renderer/gameserver/news.ts +++ b/src/renderer/gameserver/news.ts @@ -26,6 +26,9 @@ export namespace News { // Fetches only the most recent entry function request(url:string):Promise{ return new Promise((res, rej)=>{ var xhr = new XMLHttpRequest(); + xhr.addEventListener("error", (ev)=>{ + rej(ev); + }); xhr.open('GET', url); xhr.onload = function() { if (xhr.status === 200) { -- cgit v1.2.3-60-g2f50