An error message is untrusted content
Even a server-provided message can include unexpected punctuation, reflected input or operational detail. Classifying an error for retry decisions and deciding what a user should see are separate tasks. A useful message identifies the blocked action and next safe step.
What to do next
- 01
Define public error variants
Create a small message catalog for validation, unavailable models, spending limits and stale results, using your own localized wording. Keep a separate fallback that admits the operation could not be confirmed without inventing a cause.
- 02
Render as text
Use ordinary text rendering for error strings and avoid raw HTML insertion. Give developer diagnostics a restricted storage path, redacting secrets and user media references before they enter logs or support tools.
- 03
Exercise hostile messages
Test messages containing tags, long text, control characters and a fake internal URL. Confirm that users see safe text, the layout remains usable, and a support reference links to the correct internal incident evidence.
A concrete example
Illustrative example: an unexpected response contains a long gateway traceback. The customer sees We could not check this result; reference R42. Authorized operators can inspect the redacted diagnostic behind R42 without displaying it in the public page.
Before you call it ready
- Markup remains inert.
- No private URL reaches the banner.
- Every fallback has a practical next action.
When to stop or choose another method
Stop forwarding raw exception messages to customers when their contents and disclosure scope have not been reviewed.
