mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-21 19:22:13 -08:00
Hopefully catch all errors during launch process.
This commit is contained in:
parent
e3af7669d8
commit
e639061fa8
@ -103,24 +103,29 @@ function setLaunchEnabled(val){
|
||||
// Bind launch button
|
||||
document.getElementById('launch_button').addEventListener('click', async e => {
|
||||
loggerLanding.info('Launching game..')
|
||||
const server = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer())
|
||||
const mcVersion = server.rawServer.minecraftVersion
|
||||
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
||||
if(jExe == null){
|
||||
await asyncSystemScan(server.effectiveJavaOptions)
|
||||
} else {
|
||||
|
||||
setLaunchDetails(Lang.queryJS('landing.launch.pleaseWait'))
|
||||
toggleLaunchArea(true)
|
||||
setLaunchPercentage(0, 100)
|
||||
|
||||
const details = await validateSelectedJvm(ensureJavaDirIsRoot(jExe), server.effectiveJavaOptions.supported)
|
||||
if(details != null){
|
||||
loggerLanding.info('Jvm Details', details)
|
||||
await dlAsync()
|
||||
} else {
|
||||
try {
|
||||
const server = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer())
|
||||
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
||||
if(jExe == null){
|
||||
await asyncSystemScan(server.effectiveJavaOptions)
|
||||
} else {
|
||||
|
||||
setLaunchDetails(Lang.queryJS('landing.launch.pleaseWait'))
|
||||
toggleLaunchArea(true)
|
||||
setLaunchPercentage(0, 100)
|
||||
|
||||
const details = await validateSelectedJvm(ensureJavaDirIsRoot(jExe), server.effectiveJavaOptions.supported)
|
||||
if(details != null){
|
||||
loggerLanding.info('Jvm Details', details)
|
||||
await dlAsync()
|
||||
|
||||
} else {
|
||||
await asyncSystemScan(server.effectiveJavaOptions)
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
loggerLanding.error('Unhandled error in during launch process.', err)
|
||||
showLaunchFailure('Error During Launch', 'See console (CTRL + Shift + i) for more details.')
|
||||
}
|
||||
})
|
||||
|
||||
@ -319,9 +324,14 @@ async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){
|
||||
)
|
||||
setOverlayHandler(() => {
|
||||
setLaunchDetails('Preparing Java Download..')
|
||||
|
||||
downloadJava(effectiveJavaOptions, launchAfter)
|
||||
toggleOverlay(false)
|
||||
|
||||
try {
|
||||
downloadJava(effectiveJavaOptions, launchAfter)
|
||||
} catch(err) {
|
||||
loggerLanding.error('Unhandled error in Java Download', err)
|
||||
showLaunchFailure('Error During Java Download', 'See console (CTRL + Shift + i) for more details.')
|
||||
}
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
$('#overlayContent').fadeOut(250, () => {
|
||||
@ -374,6 +384,10 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
|
||||
ConfigManager.getDataDirectory(),
|
||||
effectiveJavaOptions.distribution)
|
||||
|
||||
if(asset == null) {
|
||||
throw new Error('Failed to find OpenJDK distribution.')
|
||||
}
|
||||
|
||||
let received = 0
|
||||
await downloadFile(asset.url, asset.path, ({ transferred }) => {
|
||||
received = transferred
|
||||
@ -385,9 +399,8 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
|
||||
loggerLanding.warn(`Java Download: Expected ${asset.size} bytes but received ${received}`)
|
||||
if(!await validateLocalFile(asset.path, asset.algo, asset.hash)) {
|
||||
log.error(`Hashes do not match, ${asset.id} may be corrupted.`)
|
||||
|
||||
// TODO Make error handling graceful.
|
||||
throw new Error('JDK download had problems')
|
||||
// Don't know how this could happen, but report it.
|
||||
throw new Error('Downloaded JDK has bad hash, file may be corrupted.')
|
||||
}
|
||||
}
|
||||
|
||||
@ -492,18 +505,32 @@ async function dlAsync(login = true) {
|
||||
|
||||
loggerLaunchSuite.info('Validating files.')
|
||||
setLaunchDetails('Validating file integrity..')
|
||||
const invalidFileCount = await fullRepairModule.verifyFiles(percent => {
|
||||
setLaunchPercentage(percent)
|
||||
})
|
||||
setLaunchPercentage(100)
|
||||
let invalidFileCount = 0
|
||||
try {
|
||||
invalidFileCount = await fullRepairModule.verifyFiles(percent => {
|
||||
setLaunchPercentage(percent)
|
||||
})
|
||||
setLaunchPercentage(100)
|
||||
} catch (err) {
|
||||
loggerLaunchSuite.error('Error during file validation.')
|
||||
showLaunchFailure('Error During File Verification', err.displayable || 'See console (CTRL + Shift + i) for more details.')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if(invalidFileCount > 0) {
|
||||
loggerLaunchSuite.info('Downloading files.')
|
||||
setLaunchDetails('Downloading files..')
|
||||
await fullRepairModule.download(percent => {
|
||||
setDownloadPercentage(percent)
|
||||
})
|
||||
setDownloadPercentage(100)
|
||||
try {
|
||||
await fullRepairModule.download(percent => {
|
||||
setDownloadPercentage(percent)
|
||||
})
|
||||
setDownloadPercentage(100)
|
||||
} catch(err) {
|
||||
loggerLaunchSuite.error('Error during file download.')
|
||||
showLaunchFailure('Error During File Download', err.displayable || 'See console (CTRL + Shift + i) for more details.')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
loggerLaunchSuite.info('No invalid files, skipping download.')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user