Home / Learn Secure SQL / Generic Errors to Users
Generic Errors to Users
A short, non-technical message on screen, always.
Quick summaryA short, non-technical message on screen, always.
How to think about this
What it is
Whatever actually went wrong internally, the message shown to an end user should be short, generic, and non-technical: "Something went wrong. Please try again."
Why it matters
A detailed error shown to a user (a query, a table name, a stack trace) hands useful information to anyone probing the application, and provides no real benefit to a legitimate user who cannot act on that detail anyway.
Mechanically speaking
Catch errors at the outermost layer of your request handling, log the full detail internally (next lesson), and return a fixed, generic message and status code to the client.
Shows up in
- Web application code review
- Backend development
- Database administration
app.use((err, req, res, next) => {
logger.error({ err, path: req.path }); // full detail, internal only
res.status(500).json({ error: 'Something went wrong. Please try again.' });
});Check yourself
1. An end user facing an error should see...
Generic message only.