Designing Developer-Friendly Error Messages: Principles and Real-World Examples
The article examines how developers typically cope with errors, argues for richer error messages that aid troubleshooting, and showcases effective error‑handling designs through Rust’s compiler diagnostics and the Scoop installer’s automated issue system, while proposing four key principles and several practical patterns for presenting errors.
Why Better Error Messages Matter
Developers usually deal with errors in three ways: copying solutions from Stack Overflow, Googling the error message, or (jokingly) blaming the user. To support the first two approaches, error output must contain sufficient information.
Simple Help‑Flag Mechanism
Providing a --help flag can guide developers to relevant resources.
Case Study: Rust Compiler
Rust’s compiler delivers friendly diagnostics. For example, omitting a main function produces:
error[E0601]: `main` function not found in crate `lumos`
--> src/main.rs:1:1
...
error: could not compile `lumos` due to previous errorThe message suggests running rustc --explain E0601 to get detailed markdown documentation. This approach includes:
Error‑code maintenance.
Markdown files for easy updates.
Cross‑platform terminal rendering (e.g., using less).
Extensible design that integrates with IDEs.
Case Study: Scoop Installer
Scoop, an open‑source Windows command‑line installer, automates error handling by:
Generating a GitHub issue link for the failure.
Running a GitHub Action to reproduce the error.
Attempting an automated fix or suggesting a solution.
Examples: https://github.com/ScoopInstaller/Main/issues/2711 and the related GitHub Actions repository https://github.com/shovel-org/GithubActions.
Four Elements of Effective Error Presentation
Human‑centered and friendly information, never blaming the user.
Learning experience: guide from error code to resources such as issue trackers.
Consistency with industry standards and other APIs.
Preventive feedback to avoid the error in the first place.
Design Patterns for Error Presentation
Based on the principles, several patterns are proposed:
Help‑oriented design : include searchable details for Google or issue trackers.
Automatic solution suggestions : suggest commands or fixes directly in the CLI.
Embedded documentation : ship error‑code explanations with the tool.
Automated issue management : create and handle GitHub issues via actions.
Community contributions : allow developers to improve error messages.
Other patterns such as FAQ integration and syntax‑highlighted output for easier screenshotting.
phodal
A prolific open-source contributor who constantly starts new projects. Passionate about sharing software development insights to help developers improve their KPIs. Currently active in IDEs, graphics engines, and compiler technologies.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
