LogicError
What is LogicError?
LogicError: The code runs without crashing, but produces the wrong result — the algorithm itself is incorrect. A logic error is a bug where the code runs without crashing but produces the wrong result. The VAT is calculated on the wrong amount, a discount is applied twice, or a date range excludes the last day.
Frequently asked questions about LogicError
How is LogicError used in practice?
These are the hardest bugs to catch, because nothing signals that something is wrong. No error message, no stack trace, just incorrect output that someone may notice weeks later.
What should you keep in mind with LogicError?
Automated tests are the main defence, especially tests with concrete expected values for business rules: this order with these items and this discount must cost exactly this much. Edge cases deserve attention: empty lists, zero amounts, month ends and leap years. Code review helps too, because a second person reading the logic often spots an assumption the author did not question.
At a glance
| Category | Error types |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |