try catch for potentially bad json
This commit is contained in:
parent
1d8dfb3ace
commit
e3bbfd1904
1 changed files with 51 additions and 36 deletions
|
@ -4,7 +4,18 @@ import * as windowStateKeeper from "electron-window-state";
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import * as getPort from "get-port";
|
import * as getPort from "get-port";
|
||||||
import {search} from "youtube-search-without-api-key";
|
import {search} from "youtube-search-without-api-key";
|
||||||
import { existsSync, rmSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync, unlinkSync, rmdirSync, lstatSync } from "fs";
|
import {
|
||||||
|
existsSync,
|
||||||
|
rmSync,
|
||||||
|
mkdirSync,
|
||||||
|
readdirSync,
|
||||||
|
readFileSync,
|
||||||
|
writeFileSync,
|
||||||
|
statSync,
|
||||||
|
unlinkSync,
|
||||||
|
rmdirSync,
|
||||||
|
lstatSync
|
||||||
|
} from "fs";
|
||||||
import {Stream} from "stream";
|
import {Stream} from "stream";
|
||||||
import {networkInterfaces} from "os";
|
import {networkInterfaces} from "os";
|
||||||
import * as mm from 'music-metadata';
|
import * as mm from 'music-metadata';
|
||||||
|
@ -887,6 +898,7 @@ export class BrowserWindow {
|
||||||
themePath = themePath.slice(0, -10);
|
themePath = themePath.slice(0, -10);
|
||||||
}
|
}
|
||||||
if (existsSync(join(themePath, "theme.json"))) {
|
if (existsSync(join(themePath, "theme.json"))) {
|
||||||
|
try {
|
||||||
let themeJson = JSON.parse(readFileSync(join(themePath, "theme.json"), "utf8"));
|
let themeJson = JSON.parse(readFileSync(join(themePath, "theme.json"), "utf8"));
|
||||||
themeObjects.push({
|
themeObjects.push({
|
||||||
name: themeJson.name || themeName,
|
name: themeJson.name || themeName,
|
||||||
|
@ -897,6 +909,9 @@ export class BrowserWindow {
|
||||||
commit: themeJson.commit || "",
|
commit: themeJson.commit || "",
|
||||||
pack: themeJson.pack || false,
|
pack: themeJson.pack || false,
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
themeObjects.push({
|
themeObjects.push({
|
||||||
name: themeName,
|
name: themeName,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue