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

Two faces of one errorShown to the user"Something went wrong. Pleasetry again."A generic HTTP 500 status,nothing moreLogged internallyFull error, query, and stacktraceAvailable to developersinvestigating the issue
Two faces of one error

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
A generic error handler (Express.js)
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...