Error handling is how an app behaves when something goes wrong, and what it tells people when it does.
This guide is for students, newcomers to IT and anyone who has seen a strange error page and wondered if it matters. You do not need to write code to be affected: if your business has a website or app, how it fails is part of how safe it is.
In short
- Every app hits problems, such as a missing file, a busy database or odd input. Good apps plan for this.
- A detailed error page can show attackers file paths, software versions and database details. Users should see a short, plain message instead.
- When a safety check breaks, a safe app says no (fails closed). A risky app lets the request through (fails open).
- Mishandled errors now have their own place in a well-known list of top web app risks, the OWASP Top 10.
What you will learn
- Explain what error handling means in plain words.
- Spot an error page that gives away too much.
- Explain the difference between failing open and failing closed.
- Ask your developers or web supplier the right questions.
- Something going wrong (an error)
- a problem an app meets while it works, such as a missing file or a failed connection.
- Fault report (stack trace)
- a detailed list of the steps the code took before it failed, meant for developers.
- Saying no when unsure (fail closed)
- when a check breaks, the app refuses the request instead of allowing it.
What is error handling?
Think of the electronic locks on an office building. When the power fails, each door has to do something. A door to the fire exit should open so people can leave. A door to the server room should stay locked.
Apps face the same choice many times a day. Something unexpected happens, and the app must decide what to do next and what to say. That plan is called error handling.
Good error handling does three things. It keeps the app in a safe state. It shows the user a short, plain message. And it writes the full detail into a private record, called a log, so the team can fix the problem.
Poor error handling does the opposite. It may show a page full of technical detail, or it may skip a safety check and carry on as if nothing happened.[1]
Where the comparison stops working: a building has a few doors and one power supply. An app has thousands of places where something can fail, and each one needs its own safe choice.
Why does it matter?
Attackers often break things on purpose to see what an app says back. A chatty error page can tell them exactly where to aim next.[2]
If you run a small business website
What could happen: a broken page shows the name of your database and where your files live, which helps an attacker plan.
Check this: ask your web supplier whether detailed error pages are switched off on the live site.
If you are learning to code
What could happen: you print the full error to the screen while testing and forget to change it before the app goes live.
Check this: send the detail to the log and show users one plain sentence.
If you test or support apps
What could happen: a sign-in check times out, and the app lets the person in anyway.
Check this: when you test, ask what happens if a check cannot finish. The answer should be "access refused".
What does it look like?
Here is a made-up error page from a booking site. The left half is what the public sees today. The right half is what they should see.
Example only. All values are made up.
--- What the visitor sees now --- Error 500: DatabaseError in /srv/example-app/bookings.py (1) ExampleDB 0.0 at db.example.invalid (2) query: SELECT * FROM customers WHERE id = '0000'' (3) password=FAKE-0000 (4) --- What the visitor should see --- Sorry, something went wrong. Please try again. (5) Reference: EXAMPLE-0000
- The folder where the app's code lives on the server.
- The database software, its version and its address.
- The exact database request that failed, which hints at how to attack it.
- In a real file, a line like this would contain a secret password that was in memory when the error happened.
- A plain message and a reference number. The team can match the number to the full detail in the log.
Why this is risky: the top half hands an attacker a map of the system, and in this case a password.[3]
The safer way: the visitor sees one plain line. The detail goes to a protected log that only the team can read.[2]
How does it work?
Here is what a well-built app does when something goes wrong, in simple steps.
- Something unusual happens. A file is missing, a service is slow, a user types something odd or the server runs low on memory. Security experts call these exceptional conditions, meaning situations the normal path did not expect.[1]
- The app catches the error close to where it happened. The code that knows most about the problem decides what to do. A catch-all safety net, called a global error handler, picks up anything that slips through.[1][2]
- The app returns to a safe state. If a check could not finish, the answer is no. If a payment was half done, the whole thing is undone, so money is not lost or sent twice.[1]
- The user sees a plain message. It says something went wrong and what to try next. It does not show code, paths or versions.[2]
- The detail goes to the log. The full fault report is written to a protected log. Passwords and keys should be kept out of it.[3]
- Someone watches for patterns. Many errors from one place can be a sign that someone is probing the app on purpose.[1]

The second idea, failing safely, matters even more than the message. A weakness experts call failing open means that after an error, the app drops to a less safe state. For example, it may allow access because the check that should have refused it crashed.[4]

A worked example
This story is made up to show how it can happen.
Petra Haddad runs a small online shop that sells handmade ceramics. A friend of a friend, Juno Ilic, built the site for her two years ago and still looks after it.
One evening a customer emails Petra a screenshot. They clicked an old link and got a page full of code. Petra does not understand it, but she can see the words "password" and "database" on it.
She sends the screenshot to Juno. Juno recognises the page at once. When he built the site, he switched on the detailed error display, called debug mode, to help him test. He forgot to switch it off when the site went live.
That night, Juno turns off debug mode on the live site. He adds a plain error page that says "Sorry, something went wrong" with a reference number. The full detail now goes to a log that only he can read.
Because the database password was shown on the screen, Juno changes it. He also checks the log for odd visits. In the records available to him, he sees a few people loading the broken link, but no signs that the password was used.
While testing, Juno notices something else. If the discount code service is down, the checkout skips the check and applies the discount anyway. He changes it so that the discount is refused when the check cannot finish.
What made the difference: Petra passed on a strange screenshot instead of ignoring it. Juno then treated both the message and the failure as security problems.
Myths and mistakes
| What people think | What is true |
|---|---|
| Detailed error pages help users understand the problem. | Users need a plain message. The detail helps developers and attackers, so it belongs in a protected log.[2] |
| If a check crashes, it is kinder to let the user carry on. | Letting them through is failing open. The safer choice is to refuse and let them try again.[4] |
| Errors are just bugs, not security issues. | Mishandled errors can leak data, leave tasks half done or slow an app until it stops. OWASP now lists them as a top risk.[1] |
| Debug mode only matters on test sites. | It matters most when it is left on by mistake on the live site, where anyone can see it.[3] |
| Logging everything is always safest. | Logs are useful, but they should not hold passwords or keys, and they need protecting too.[3] |
What can I do this week?
- Visit a page on your site that does not exist and see what the error page shows. To do this, add some made-up words to the end of the address.
- Ask your developer or web supplier whether debug mode is switched off on the live site.
- Ask what happens when a sign-in or payment check cannot finish. The answer you want is "the request is refused".
- Check who can read the app's logs, and that passwords and keys are kept out of them.
- If you code, add one catch-all error handler that shows a plain message and logs the detail.
Checklist
- I can explain what error handling means.
- Our live site shows plain error messages, without code, file paths or versions.
- Debug mode is switched off on the live site.
- Our sign-in and payment checks refuse the request if they cannot finish.
- Half-finished tasks, such as payments, are undone in full when something fails.
- Error details go to a protected log, without passwords or keys.
- Someone looks at error patterns, not just single errors.
Common questions
What is a stack trace, and why should users not see it?
A stack trace is a list of the steps the code took just before it failed. It helps developers find the fault. It can also show file paths, software names and versions, which helps attackers plan, so it belongs in the log, not on the screen.[2]
What does fail closed mean?
Fail closed means that when a safety check cannot give an answer, the app says no. It is like a locked door staying locked in a power cut. The opposite, fail open, lets the request through, which can let the wrong person in.[1][4]
What is the new OWASP Top 10 category about errors?
The 2025 OWASP Top 10, a widely used list of the biggest web app risks, added a category called Mishandling of Exceptional Conditions. It sits in tenth place and is new in 2025. It covers leaky error messages, failing open and tasks left half done.[1]
Is a generic error message bad for customers?
Not if it is written well. A good message says sorry, says what to try next and gives a reference number. Support staff can use that number to find the full detail in the log, so customers still get help without seeing the inner workings.[2]
Can error messages reveal whether an account exists?
Yes. A message like "no account with that email" tells an attacker which emails are signed up. A safer message says "email or password is wrong" for both cases, so it gives nothing away.[3]
Where next?
Ready for the detail? Read the practitioner guide: OWASP Top 10 A10 Guide. It goes further into what the OWASP category asks for, the matching verification requirements, implementation steps and how to show it is working.
Also useful:
- Secure Error Handling and Logging Guide
- Security Misconfiguration for Beginners
- Sensitive Data in Logs for Beginners
- Account Enumeration for Beginners
Related NHI Mgmt Group resources: The OWASP Top 10 for Beginners · Secure Coding for Beginners · SQL Injection for Beginners
Key terms
- Error handling
- The way a system detects, manages and reports failures without causing wider damage.
- Exceptional conditions
- Unusual or failure states, such as bad input, a failed service or running out of memory, that software must handle safely.
- Generic error message
- A deliberately plain message shown when something fails, which does not reveal how the system works.
- Stack trace
- A detailed error output showing the path the code took before it failed.
- Debug mode
- A setting that shows detailed diagnostic information to help developers, and that should be off on a live site.
- Fail open
- When a system falls back to a less secure state after an error, for example allowing access when a check fails.
- Fail closed
- When a system refuses a request because a check or service cannot give a confident answer.
- Error log
- A private record of faults and failures in an app, which needs protecting because it can hold sensitive details.
Sources and further reading
- A10:2025 Mishandling of Exceptional Conditions. OWASP Top 10:2025, OWASP Foundation (new category for 2025). https://top10.owasp.org/2025/A10_2025-Mishandling_of_Exceptional_Conditions/, accessed 28 Nov 2026.
- Error Handling Cheat Sheet. OWASP Cheat Sheet Series. https://cheatsheetseries.owasp.org/cheatsheets/Error_Handling_Cheat_Sheet.html, accessed 28 Nov 2026.
- CWE-209: Generation of Error Message Containing Sensitive Information. MITRE Common Weakness Enumeration. https://cwe.mitre.org/data/definitions/209.html, accessed 28 Nov 2026.
- CWE-636: Not Failing Securely ('Failing Open'). MITRE Common Weakness Enumeration. https://cwe.mitre.org/data/definitions/636.html, accessed 28 Nov 2026.