Wrap with try..catch

This commit is contained in:
Zack Rauen 2020-07-26 19:34:06 -04:00
parent cea1ba5a30
commit f2d4e3e8b7
2 changed files with 9 additions and 2 deletions

3
.github/FUNDING.yml vendored
View File

@ -0,0 +1,3 @@
github: rauenzi
patreon: Zerebos
custom: ["https://paypal.me/ZackRauen"]

View File

@ -44,8 +44,12 @@ export default new class DataStore {
fs.renameSync(oldFile, `${oldFile}.bak`); // rename file after grabbing data to prevent loop
const setChannelData = (channel, key, value, ext = "json") => fs.writeFileSync(path.resolve(this.baseFolder, channel, `${key}.${ext}`), JSON.stringify(value, null, 4));
const channels = ["stable", "canary", "ptb"];
const customcss = atob(oldData.bdcustomcss);
const favoriteEmotes = oldData.bdfavemotes ? JSON.parse(atob(oldData.bdfavemotes)) : "";
let customcss = "";
let favoriteEmotes = {};
try {customcss = oldData.bdcustomcss ? atob(oldData.bdcustomcss) : "";}
catch (e) {console.error(e);} // eslint-disable-line no-console
try {favoriteEmotes = oldData.bdfavemotes ? JSON.parse(atob(oldData.bdfavemotes)) : {};}
catch (e) {console.error(e);} // eslint-disable-line no-console
for (const channel of channels) {
if (!fs.existsSync(path.resolve(this.baseFolder, channel))) fs.mkdirSync(path.resolve(this.baseFolder, channel));
const channelData = oldData.settings[channel];