Skip to content
AgileLogics
Intermediate 4 min read

Error Handling

Prerequisites: Conditions

An error (also called an exception) is what happens when something goes wrong while a program is running — a file doesn't exist, a network request fails, a user types text where a number was expected.

Real-world analogy: error handling is like a smoke detector plan — you don't prevent every possible fire, but you plan for what happens when one is detected, instead of being caught completely off guard.

try:
    result = 10 / number
catch error:
    print("Couldn't divide:", error)

Handling errors deliberately — instead of letting the whole program crash — is what separates a fragile script from reliable software.