Long error messages should be cut in production
See original GitHub issueAs noted by @blesh in https://twitter.com/BenLesh/status/727659194711597056, we should gate long error messages:
if (process.env.NODE_ENV === 'production') {
throw new Error('short message');
} else {
throw new Error('long message');
}
This way Uglify can dead-code eliminate the long version in the minified builds.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Error Messages: Examples, Best Practices & Common Mistakes
Useful error messages can keep users on your site and increase conversions. See examples and learn the best practices.
Read more >Error Message Guidelines - Nielsen Norman Group
Established wisdom holds that good error messages are polite, precise, and constructive. The Web brings a few new guidelines: Make error messages clearly ......
Read more >7 Steps To Have Impressive Error Messages | by Amisiy | Muzli
2- Be Clear and Concise. No one wants to read long texts, even for the most important things — let alone to fix...
Read more >How to write a great error message | by Thomas Fuchs | Medium
You've worked long hours this week for an upcoming product introduction. ... let's have a look at what a great error message should...
Read more >Error Screens and Messages: UX Design Practices - Tubik Blog
The article shares insights on the UX design of error screens and writing error messages: learn how to smoothen the negative effect of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The one important thing is to have consistent throwing behavior in dev and prod. Giving a shorter message in prod is fine, but throwing only in dev is problematic because it makes app behaves inconsistently.
How it usually works: DefinePlugin/envify just replace
process.env.NODE_ENV
with a string. However it is Uglify that actually removesif ('production' !== 'production')
blocks as dead code.