eli5: In programming, how does using “try and except/catch” blocks stop the program from crashing?

609 views

eli5: In programming, how does using “try and except/catch” blocks stop the program from crashing?

In: 10

20 Answers

Anonymous 0 Comments

Using try and catch you can tell the program what to do in case of an error and not just die horribly; ie usually recover gracefully. You can have something like try { open a file } catch { (if file not found) tell user it’s not found and return “no file found sorry” } otherwise it would be that if file not found -> crash and exit process

You are viewing 1 out of 20 answers, click here to view all answers.