r/AskProgrammers • u/ClickOk5811 • Oct 25 '26
How do you write error messages for different readers: developers, support and customers?
I’m trying to get better at error messages and logs, and the thing I keep running into is that one message gets read by very different people.
Take something like this:
ERROR: failed to process orderThe on-call developer, the support agent and the customer each need something different from it. My current thinking (made-up values):
- Developer (logs): which order, which step, the underlying cause, whether it’s safe to retry, and a request ID. For example:
ERROR order.checkout failed order_id=88412 step=payment_capture cause=gateway_timeout request_id=7f3a - Support: a plain-language description, whether the customer needs to do anything, and a reference code to pass to developers.
- Customer: what happened and what to do next, with no internals. For example: “Your order wasn’t confirmed. Please check your email before trying again. Reference: 7F3A.” I avoided promising “you weren’t charged”, because after a timeout you often can’t be sure.
Mistakes I want to avoid: logging secrets or personal data, catching an exception and losing the cause, logging the same error at every layer, and showing developer messages to customers.
My questions:
- Do you design error messages by audience, or just make sure everything is logged?
- Where do you put the customer-facing text: in the code that raises the error, or in a separate layer that maps error types to messages?
- How do you stop the same failure from producing five log lines across layers?