Is Try Catch Good Practice

It is used to handle run time exceptions. It is a good practice to write the code in try block which may generate an error , so, that the code doesn’t terminate abruptly.

Is it a good practice to use try catch?

It is perfectly fine to use two try/catch blocks if the algorithm requires it. I have often used a new try/catch in a catch block to ensure a safe cleanup so a blanket statement is not possible.

Is try catch good practice in Javascript?

It’s a good idea to create and implement custom errors that extend the base error class. Try catch is not meant to be a tool that makes up for bad code. Implementing try catch isn’t meant to be a tool to make up for bad code.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest