Home / Learn Secure SQL / Reading Database Errors Safely
Reading Database Errors Safely
What an error message is allowed to tell you, and who.
Theory in plain words
The basic idea
Database error messages are extremely useful to a developer during development, and can be dangerous if shown, unfiltered, to an end user in production.
Why this comes up
An error message often contains the exact SQL that failed, table and column names, or even data. That is exactly the kind of detail that should stay internal.
The mechanics
In development, read the full error. In production, log the full error internally and show the user a short, generic message.
Where it is used
- Web application code review
- Backend development
- Database administration
Try it
This fails on purpose because the column is misspelled. Read the error text the sandbox shows: it names the exact column. That is useful to you here, but should never reach a real end user screen.
Quick check
1. A raw database error is best shown to...
Internal logs, not the public screen.