Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use warn instead of error for warnings #94

Closed
wants to merge 1 commit into from

Conversation

sean-clayton
Copy link

console.warn is both visually and semantically correct for displaying warnings than console.error. I recommend switching to it 👍

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@zpao
Copy link
Member

zpao commented Jan 1, 2016

Thanks but we're not going to take this. We intentionally changed to using console.error to improve the debugging experience, namely that you get native logging of stack traces.

@zpao zpao closed this Jan 1, 2016
@sean-clayton
Copy link
Author

@zpao Why not use console.trace() in conjunction?

@sophiebits
Copy link
Contributor

console.trace would probably be okay, though the yellow/red background is something we also want to keep. We also generally only use warning() for "must-fix" warnings where you really should fix them, so I don't mind the harshness of console.error. At Facebook internally we use an alert()-like modal dialog for all warnings to ensure they're seen.

@SimplyLinn
Copy link

SimplyLinn commented Nov 19, 2016

I have to agree with @sean-clayton on this. The facebook way of seeing warnings as more severe and display them as errors is really taxing on people used with the notion that "Big red bad error means the execution in a task has halted and not completed" while a warning means "Something went wrong during execution, but it did not necessarily halt."

Using big red messages saying "THE PROGRAM HAS HALTED AT THIS LINE PANIC!" when all you really mean is "You have a rather severe problem on line X, I can work around it, but fix it." goes against what both the browsers themselves are outputting into the console (errors for failed HTTP-requests, warnings when stuff do not have the correct content-type header, but the correct content-type header can be deduced etc.)

Not conforming to this de-facto standard within the JS community means you're in a sense isolating you're possibly hiding important fatal errors among your warnings, making debugging harder than it usually is. When I'm trying to fix a fatal error, I want the warning to be a warning, and the fatal error to be a fatal error. Warnings and errors are not equal!

A compromise would be to use non-fatal errors and call them that, errors if that's what you mean. But seeing "Warning: " in a console.error-log is just a contradiction.

@mellis481
Copy link

mellis481 commented Jun 27, 2024

@zpao How does using console.error in a function called warning() and where the message being logged starts with "Warning:" not make you feel like you're doing something wrong/hacky?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants