diff --git a/experiments/automatedScreenshots/shooter.js b/experiments/automatedScreenshots/shooter.js index a6baa1de..4c71146e 100644 --- a/experiments/automatedScreenshots/shooter.js +++ b/experiments/automatedScreenshots/shooter.js @@ -35,9 +35,13 @@ class Shooter { _validateZip(u) { return new Promise((resolve, reject) => { - fs.readFile(u, (err, buffer) => { - JSZip.loadAsync(buffer).then(resolve, reject); - }); + try { + fs.readFile(u, (err, buffer) => { + JSZip.loadAsync(buffer).then(resolve, reject); + }); + } catch (e) { + reject(e); + } }); } diff --git a/js/actionCreators/files.js b/js/actionCreators/files.js index 25299a37..e0aaf14e 100644 --- a/js/actionCreators/files.js +++ b/js/actionCreators/files.js @@ -82,16 +82,22 @@ export function loadFilesFromReferences( export function setSkinFromArrayBuffer(arrayBuffer) { return async dispatch => { dispatch({ type: LOADING }); - const skinData = await skinParser(arrayBuffer); - dispatch({ - type: SET_SKIN_DATA, - skinImages: skinData.images, - skinColors: skinData.colors, - skinPlaylistStyle: skinData.playlistStyle, - skinCursors: skinData.cursors, - skinRegion: skinData.region, - skinGenLetterWidths: skinData.genLetterWidths - }); + try { + const skinData = await skinParser(arrayBuffer); + dispatch({ + type: SET_SKIN_DATA, + skinImages: skinData.images, + skinColors: skinData.colors, + skinPlaylistStyle: skinData.playlistStyle, + skinCursors: skinData.cursors, + skinRegion: skinData.region, + skinGenLetterWidths: skinData.genLetterWidths + }); + } catch (e) { + console.error(e); + dispatch({ type: LOADED }); + alert(`Failed to parse skin`); + } }; }