Error Types Formula
Error types are the main categories of mistakes that can occur in a program.
The Formula
Ask yourself: Is the job to label a mistake as one that stops the code starting, crashes it partway, or gives a wrong answer?
Quick example
What this formula means
Error types are the main categories of mistakes that can occur in a program. The most common categories are syntax errors (the code is written incorrectly), runtime errors (the program crashes while running), and logic errors (the program runs but gives the wrong answer).
Error types are like mistakes in a recipe. A smudged line nobody can read is a syntax error: the cook cannot use the recipe. 'Add the eggs' when there are no eggs is a runtime error: cooking stops partway. 'Bake at 400 °C' instead of 200 °C is a logic error: every step is done exactly as written, and the cake is ruined.
Formal view
Worked examples
Example 1
mediumShow solution
Answer
First step
See the full worked solution + why-it-works coaching
SetupKey insightWhy it worksCommon pitfallConnection
Example 2
mediumExample 3
mediumCommon mistakes
- Calling every wrong answer a syntax problem even when the code runs
- Fixing one runtime crash without checking whether a deeper logic problem remains
- Ignoring compiler or interpreter messages that already identify the error category
Common mistakes guide
If this formula keeps breaking in real problems, read the most common errors before you practice again.
Why this formula matters
Each type needs a different search: syntax errors are found by reading the error message, runtime errors by finding the input that triggers the crash, and logic errors only by testing against known answers. Logic errors are the dangerous ones. A grade calculator that averages wrongly still prints a neat, believable number, and nobody notices until someone checks by hand.
Frequently asked questions
What is the Error Types formula?
Error types are the main categories of mistakes that can occur in a program. The most common categories are syntax errors (the code is written incorrectly), runtime errors (the program crashes while running), and logic errors (the program runs but gives the wrong answer).
How do you use the Error Types formula?
Use error types when you have to classify a problem in a program from an error message, a crash, or an output that is simply wrong. Clues: 'SyntaxError' or 'won't start' point to syntax; 'division by zero' or 'index out of range' partway through point to runtime; 'runs but the total is wrong' points to logic. Once the type is named, finding and fixing the actual line is Debugging. Choosing the inputs that reveal errors is Testing.
Why is the Error Types formula important in CS Thinking?
Each type needs a different search: syntax errors are found by reading the error message, runtime errors by finding the input that triggers the crash, and logic errors only by testing against known answers. Logic errors are the dangerous ones. A grade calculator that averages wrongly still prints a neat, believable number, and nobody notices until someone checks by hand.
What do students get wrong about Error Types?
Logic errors are often the hardest because the program still runs, so the bug is less obvious.
What should I learn before the Error Types formula?
Before studying the Error Types formula, you should understand: debugging.