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

1.07K views

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

In: 10

20 Answers

Anonymous 0 Comments

When an exception is thrown, it “bubbles up” until it’s “caught” and handled by something. If nothing catches it, the execution environment will handle it, which it usually does by closing the program. If you catch it yourself you can have the program gracefully recover from the error, or at least log the error appropriately before you close the program yourself.

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