Hopefully catch all errors during launch process.
This commit is contained in:
parent
e3af7669d8
commit
e639061fa8
@ -103,8 +103,8 @@ function setLaunchEnabled(val){
|
|||||||
// Bind launch button
|
// Bind launch button
|
||||||
document.getElementById('launch_button').addEventListener('click', async e => {
|
document.getElementById('launch_button').addEventListener('click', async e => {
|
||||||
loggerLanding.info('Launching game..')
|
loggerLanding.info('Launching game..')
|
||||||
|
try {
|
||||||
const server = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer())
|
const server = (await DistroAPI.getDistribution()).getServerById(ConfigManager.getSelectedServer())
|
||||||
const mcVersion = server.rawServer.minecraftVersion
|
|
||||||
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
const jExe = ConfigManager.getJavaExecutable(ConfigManager.getSelectedServer())
|
||||||
if(jExe == null){
|
if(jExe == null){
|
||||||
await asyncSystemScan(server.effectiveJavaOptions)
|
await asyncSystemScan(server.effectiveJavaOptions)
|
||||||
@ -118,10 +118,15 @@ document.getElementById('launch_button').addEventListener('click', async e => {
|
|||||||
if(details != null){
|
if(details != null){
|
||||||
loggerLanding.info('Jvm Details', details)
|
loggerLanding.info('Jvm Details', details)
|
||||||
await dlAsync()
|
await dlAsync()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
await asyncSystemScan(server.effectiveJavaOptions)
|
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.')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Bind settings button
|
// Bind settings button
|
||||||
@ -319,9 +324,14 @@ async function asyncSystemScan(effectiveJavaOptions, launchAfter = true){
|
|||||||
)
|
)
|
||||||
setOverlayHandler(() => {
|
setOverlayHandler(() => {
|
||||||
setLaunchDetails('Preparing Java Download..')
|
setLaunchDetails('Preparing Java Download..')
|
||||||
|
|
||||||
downloadJava(effectiveJavaOptions, launchAfter)
|
|
||||||
toggleOverlay(false)
|
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(() => {
|
setDismissHandler(() => {
|
||||||
$('#overlayContent').fadeOut(250, () => {
|
$('#overlayContent').fadeOut(250, () => {
|
||||||
@ -374,6 +384,10 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
|
|||||||
ConfigManager.getDataDirectory(),
|
ConfigManager.getDataDirectory(),
|
||||||
effectiveJavaOptions.distribution)
|
effectiveJavaOptions.distribution)
|
||||||
|
|
||||||
|
if(asset == null) {
|
||||||
|
throw new Error('Failed to find OpenJDK distribution.')
|
||||||
|
}
|
||||||
|
|
||||||
let received = 0
|
let received = 0
|
||||||
await downloadFile(asset.url, asset.path, ({ transferred }) => {
|
await downloadFile(asset.url, asset.path, ({ transferred }) => {
|
||||||
received = transferred
|
received = transferred
|
||||||
@ -385,9 +399,8 @@ async function downloadJava(effectiveJavaOptions, launchAfter = true) {
|
|||||||
loggerLanding.warn(`Java Download: Expected ${asset.size} bytes but received ${received}`)
|
loggerLanding.warn(`Java Download: Expected ${asset.size} bytes but received ${received}`)
|
||||||
if(!await validateLocalFile(asset.path, asset.algo, asset.hash)) {
|
if(!await validateLocalFile(asset.path, asset.algo, asset.hash)) {
|
||||||
log.error(`Hashes do not match, ${asset.id} may be corrupted.`)
|
log.error(`Hashes do not match, ${asset.id} may be corrupted.`)
|
||||||
|
// Don't know how this could happen, but report it.
|
||||||
// TODO Make error handling graceful.
|
throw new Error('Downloaded JDK has bad hash, file may be corrupted.')
|
||||||
throw new Error('JDK download had problems')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,18 +505,32 @@ async function dlAsync(login = true) {
|
|||||||
|
|
||||||
loggerLaunchSuite.info('Validating files.')
|
loggerLaunchSuite.info('Validating files.')
|
||||||
setLaunchDetails('Validating file integrity..')
|
setLaunchDetails('Validating file integrity..')
|
||||||
const invalidFileCount = await fullRepairModule.verifyFiles(percent => {
|
let invalidFileCount = 0
|
||||||
|
try {
|
||||||
|
invalidFileCount = await fullRepairModule.verifyFiles(percent => {
|
||||||
setLaunchPercentage(percent)
|
setLaunchPercentage(percent)
|
||||||
})
|
})
|
||||||
setLaunchPercentage(100)
|
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) {
|
if(invalidFileCount > 0) {
|
||||||
loggerLaunchSuite.info('Downloading files.')
|
loggerLaunchSuite.info('Downloading files.')
|
||||||
setLaunchDetails('Downloading files..')
|
setLaunchDetails('Downloading files..')
|
||||||
|
try {
|
||||||
await fullRepairModule.download(percent => {
|
await fullRepairModule.download(percent => {
|
||||||
setDownloadPercentage(percent)
|
setDownloadPercentage(percent)
|
||||||
})
|
})
|
||||||
setDownloadPercentage(100)
|
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 {
|
} else {
|
||||||
loggerLaunchSuite.info('No invalid files, skipping download.')
|
loggerLaunchSuite.info('No invalid files, skipping download.')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user