Reject if the distribution json is invalid, displaying the error overlay instead of looping.
This commit is contained in:
parent
46853157ec
commit
86647eb53a
@ -546,11 +546,11 @@ 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){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
data = DistroIndex.fromJSON(JSON.parse(body))
|
data = DistroIndex.fromJSON(JSON.parse(body))
|
||||||
} catch (e) {
|
resolve(data)
|
||||||
reject(e)
|
} catch(e) {
|
||||||
|
reject('We cannot parse the JSON in the remote distribution file')
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFile(distroDest, body, 'utf-8', (err) => {
|
fs.writeFile(distroDest, body, 'utf-8', (err) => {
|
||||||
@ -574,8 +574,12 @@ exports.pullLocal = function(){
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
fs.readFile(DEV_MODE ? DEV_PATH : DISTRO_PATH, 'utf-8', (err, d) => {
|
fs.readFile(DEV_MODE ? DEV_PATH : DISTRO_PATH, 'utf-8', (err, d) => {
|
||||||
if(!err){
|
if(!err){
|
||||||
data = DistroIndex.fromJSON(JSON.parse(d))
|
try {
|
||||||
resolve(data)
|
data = DistroIndex.fromJSON(JSON.parse(d))
|
||||||
|
resolve(data)
|
||||||
|
} catch(e) {
|
||||||
|
reject('We cannot parse the JSON in the local distribution file')
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
reject(err)
|
reject(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user