There are different ways code might not work. The one we’re talking about here is when you break a rule the code has somewhere. Like this function only works with numbers and that one only works with words. If you break the rules, the code tells you it can’t do that by ‘throwing an exception.’ It knows to do that because the person who wrote that bit of code told it to.
You can tell the computer “hey, if this breaks any rules, do this other thing instead.”
If code would cause the whole computer to crash, try/catch might not help.
Latest Answers