question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Long error messages should be cut in production

See original GitHub issue

As 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:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
gaearoncommented, May 5, 2016

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.

1reaction
gaearoncommented, May 4, 2016

How it usually works: DefinePlugin/envify just replace process.env.NODE_ENV with a string. However it is Uglify that actually removes if ('production' !== 'production') blocks as dead code.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found