mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 03:32:12 -08:00
Improve error handling during launch (#21)
If anything happens to the forked process, the main should now pick up on it and alert the user. Should no longer get 'stuck at 100%' issues when the forked process fails, for whatever reason.
This commit is contained in:
parent
cb12c0786e
commit
8c0bf8faac
@ -534,7 +534,12 @@ exports.pullRemote = function(){
|
|||||||
const distroDest = path.join(ConfigManager.getLauncherDirectory(), 'distribution.json')
|
const distroDest = path.join(ConfigManager.getLauncherDirectory(), 'distribution.json')
|
||||||
request(opts, (error, resp, body) => {
|
request(opts, (error, resp, body) => {
|
||||||
if(!error){
|
if(!error){
|
||||||
data = DistroIndex.fromJSON(JSON.parse(body))
|
|
||||||
|
try {
|
||||||
|
data = DistroIndex.fromJSON(JSON.parse(body))
|
||||||
|
} catch (e) {
|
||||||
|
reject(e)
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFile(distroDest, body, 'utf-8', (err) => {
|
fs.writeFile(distroDest, body, 'utf-8', (err) => {
|
||||||
if(!err){
|
if(!err){
|
||||||
|
@ -254,6 +254,23 @@ refreshMojangStatuses()
|
|||||||
let mojangStatusListener = setInterval(() => refreshMojangStatuses(true), 300000)
|
let mojangStatusListener = setInterval(() => refreshMojangStatuses(true), 300000)
|
||||||
let serverStatusListener = setInterval(() => refreshServerStatus(true), 300000)
|
let serverStatusListener = setInterval(() => refreshServerStatus(true), 300000)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows an error overlay, toggles off the launch area.
|
||||||
|
*
|
||||||
|
* @param {string} title The overlay title.
|
||||||
|
* @param {string} desc The overlay description.
|
||||||
|
*/
|
||||||
|
function showLaunchFailure(title, desc){
|
||||||
|
setOverlayContent(
|
||||||
|
title,
|
||||||
|
desc,
|
||||||
|
'Okay'
|
||||||
|
)
|
||||||
|
setOverlayHandler(null)
|
||||||
|
toggleOverlay(true)
|
||||||
|
toggleLaunchArea(false)
|
||||||
|
}
|
||||||
|
|
||||||
/* System (Java) Scan */
|
/* System (Java) Scan */
|
||||||
|
|
||||||
let sysAEx
|
let sysAEx
|
||||||
@ -495,6 +512,16 @@ function dlAsync(login = true){
|
|||||||
aEx.stdio[2].on('data', (data) => {
|
aEx.stdio[2].on('data', (data) => {
|
||||||
loggerAEx.log(data)
|
loggerAEx.log(data)
|
||||||
})
|
})
|
||||||
|
aEx.on('error', (err) => {
|
||||||
|
loggerLaunchSuite.error('Error during launch', err)
|
||||||
|
showLaunchFailure('Error During Launch', err.message || 'See console (CTRL + Shift + i) for more details.')
|
||||||
|
})
|
||||||
|
aEx.on('close', (code, signal) => {
|
||||||
|
if(code !== 0){
|
||||||
|
loggerLaunchSuite.error(`AssetExec exited with code ${code}, assuming error.`)
|
||||||
|
showLaunchFailure('Error During Launch', 'See console (CTRL + Shift + i) for more details.')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Establish communications between the AssetExec and current process.
|
// Establish communications between the AssetExec and current process.
|
||||||
aEx.on('message', (m) => {
|
aEx.on('message', (m) => {
|
||||||
@ -575,24 +602,18 @@ function dlAsync(login = true){
|
|||||||
loggerLaunchSuite.error('Error while downloading:', m.error)
|
loggerLaunchSuite.error('Error while downloading:', m.error)
|
||||||
|
|
||||||
if(m.error.code === 'ENOENT'){
|
if(m.error.code === 'ENOENT'){
|
||||||
setOverlayContent(
|
showLaunchFailure(
|
||||||
'Download Error',
|
'Download Error',
|
||||||
'Could not connect to the file server. Ensure that you are connected to the internet and try again.',
|
'Could not connect to the file server. Ensure that you are connected to the internet and try again.'
|
||||||
'Okay'
|
|
||||||
)
|
)
|
||||||
setOverlayHandler(null)
|
|
||||||
} else {
|
} else {
|
||||||
setOverlayContent(
|
showLaunchFailure(
|
||||||
'Download Error',
|
'Download Error',
|
||||||
'Check the console for more details. Please try again.',
|
'Check the console (CTRL + Shift + i) for more details. Please try again.'
|
||||||
'Okay'
|
|
||||||
)
|
)
|
||||||
setOverlayHandler(null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remote.getCurrentWindow().setProgressBar(-1)
|
remote.getCurrentWindow().setProgressBar(-1)
|
||||||
toggleOverlay(true)
|
|
||||||
toggleLaunchArea(false)
|
|
||||||
|
|
||||||
// Disconnect from AssetExec
|
// Disconnect from AssetExec
|
||||||
aEx.disconnect()
|
aEx.disconnect()
|
||||||
@ -644,14 +665,7 @@ function dlAsync(login = true){
|
|||||||
data = data.trim()
|
data = data.trim()
|
||||||
if(data.indexOf('Could not find or load main class net.minecraft.launchwrapper.Launch') > -1){
|
if(data.indexOf('Could not find or load main class net.minecraft.launchwrapper.Launch') > -1){
|
||||||
loggerLaunchSuite.error('Game launch failed, LaunchWrapper was not downloaded properly.')
|
loggerLaunchSuite.error('Game launch failed, LaunchWrapper was not downloaded properly.')
|
||||||
setOverlayContent(
|
showLaunchFailure('Error During Launch', 'The main file, LaunchWrapper, failed to download properly. As a result, the game cannot launch.<br><br>To fix this issue, temporarily turn off your antivirus software and launch the game again.<br><br>If you have time, please <a href="https://github.com/WesterosCraftCode/ElectronLauncher/issues">submit an issue</a> and let us know what antivirus software you use. We\'ll contact them and try to straighten things out.')
|
||||||
'Error During Launch',
|
|
||||||
'The main file, LaunchWrapper, failed to download properly. As a result, the game cannot launch.<br><br>To fix this issue, temporarily turn off your antivirus software and launch the game again.<br><br>If you have time, please <a href="https://github.com/WesterosCraftCode/ElectronLauncher/issues">submit an issue</a> and let us know what antivirus software you use. We\'ll contact them and try to straighten things out.',
|
|
||||||
'Okay'
|
|
||||||
)
|
|
||||||
setOverlayHandler(null)
|
|
||||||
toggleOverlay(true)
|
|
||||||
toggleLaunchArea(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,14 +695,7 @@ function dlAsync(login = true){
|
|||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|
||||||
loggerLaunchSuite.error('Error during launch', err)
|
loggerLaunchSuite.error('Error during launch', err)
|
||||||
setOverlayContent(
|
showLaunchFailure('Error During Launch', 'Please check the console (CTRL + Shift + i) for more details.')
|
||||||
'Error During Launch',
|
|
||||||
'Please check the console for more details.',
|
|
||||||
'Okay'
|
|
||||||
)
|
|
||||||
setOverlayHandler(null)
|
|
||||||
toggleOverlay(true)
|
|
||||||
toggleLaunchArea(false)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -717,15 +724,7 @@ function dlAsync(login = true){
|
|||||||
}, (err) => {
|
}, (err) => {
|
||||||
loggerLaunchSuite.error('Unable to refresh distribution index.', err)
|
loggerLaunchSuite.error('Unable to refresh distribution index.', err)
|
||||||
if(DistroManager.getDistribution() == null){
|
if(DistroManager.getDistribution() == null){
|
||||||
setOverlayContent(
|
showLaunchFailure('Fatal Error', 'Could not load a copy of the distribution index. See the console (CTRL + Shift + i) for more details.')
|
||||||
'Fatal Error',
|
|
||||||
'Could not load a copy of the distribution index. See the console for more details.',
|
|
||||||
'Okay'
|
|
||||||
)
|
|
||||||
setOverlayHandler(null)
|
|
||||||
|
|
||||||
toggleOverlay(true)
|
|
||||||
toggleLaunchArea(false)
|
|
||||||
|
|
||||||
// Disconnect from AssetExec
|
// Disconnect from AssetExec
|
||||||
aEx.disconnect()
|
aEx.disconnect()
|
||||||
|
Loading…
Reference in New Issue
Block a user