function loadSettings(jsonText) { try { const settings = JSON.parse(jsonText); return { ok: true, theme: settings.theme, retries: settings.retries, }; } catch (error) { if (!(error instanceof SyntaxError)) { throw error; } return { ok: false, error: `${error.name}: ${error.message}`, theme: "light", retries: 0, }; } } const validSettings = loadSettings('{"theme":"dark","retries":3}'); console.log(`valid theme: ${validSettings.theme}`); console.log(`valid retries: ${validSettings.retries}`); const brokenSettings = loadSettings("{'theme':'dark'}"); console.log(`caught error: ${brokenSettings.error}`); console.log(`fallback theme: ${brokenSettings.theme}`); console.log("application still running");