Software Craftsmanship

How to Write Error Messages That Don't Make Developers Cry

How to Write Error Messages That Don't Make Developers Cry

Your error messages are UX. Treat them like it. 😭➡️😊

Bad Error Messages: ❌ "Something went wrong" ❌ "Error 500" ❌ "Invalid input" ❌ "Cannot process request" ❌ "NULL POINTER EXCEPTION"

Good Error Messages:What happened: "User authentication failed" ✅ Why it happened: "Password doesn't match our records" ✅ What to do next: "Try again or reset your password"

The 3W Formula: 🔹 What went wrong (context) 🔹 Why it happened (root cause) 🔹 What to do next (actionable solution)

Examples That Don't Suck:

🔸 API Error: "Failed to create user account. Email 'john@example.com' is already registered. Try logging in instead or use a different email."

🔸 Validation Error: "Password must be at least 8 characters and include one number. Your password 'secret' is too short and missing numbers."

🔸 Network Error: "Can't connect to payment service. This might be temporary. Try again in a few minutes or contact support if the problem persists."

Developer-Specific Tips: • Include error codes for logging/tracking • Provide stack traces in development only • Link to documentation when possible • Use consistent error response format

Good error messages turn frustration into understanding. They're the difference between a 5-minute fix and a 2-hour debugging session.

Your future self will thank you. 🙏

#ErrorHandling#UX#SoftwareDevelopment#UserExperience#CodeQuality