Home / Javascript Tips Generated By ChatGPT / Handling Exceptions with try…catch in Javascript Catch exceptions thrown in synchronous code. Source Code try { JSON.parse('not a JSON string'); } catch (error) { console.error('Failed to parse JSON', error); }