The catch block receives the error object. You can inspect it to understand what went wrong and respond appropriately.
try {
JSON.parse("invalid json");
} catch (error) {
console.log(error.name); // "SyntaxError"
console.log(error.message); // Parsing error details
}
The catch block only runs if an error occurs in the try block.