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

Formalize warnings #57

Closed
annevk opened this issue May 4, 2016 · 12 comments
Closed

Formalize warnings #57

annevk opened this issue May 4, 2016 · 12 comments
Assignees

Comments

@annevk
Copy link
Member

annevk commented May 4, 2016

Often specifications want to give hints at things that can be reported to a developer console, if there is any. Should we formalize that in the Console Standard?

(I was looking at fixing whatwg/fetch#259 and then I wondered whether we should have some shared mechanism across specifications.)

@terinjokes
Copy link
Collaborator

I like this idea, but wouldn't know where to begin in integrating it here.

@domenic
Copy link
Member

domenic commented May 6, 2016

So if you search through https://html.spec.whatwg.org/ (not the multipage version) for "developer console", it comes up a few times:

If the error is still not handled after this, then the error may be reported to a developer console.

(and several similar phrases in various points)

If any of the objects in transfer are the target port, if any, then let doomed be true, and optionally report to a developer console that the target port was posted to itself, causing the communication channel to be lost.

If the value doesn't compile successfully, user agents are encouraged to log this fact in a developer console, to aid debugging.

User agents are encouraged to log the precise cause in a developer console, to aid debugging.

(although that section will be going away soon per whatwg/html#1207)

If any value in a is not finite (e.g. an Infinity or a NaN value), or if any value is negative (less than zero), then abort these steps (without throwing an exception; user agents could show a message on a developer console, though, as that would be helpful for debugging).

I guess maybe you'd want to define a term like "optionally warn in the developer console" which is something like "Optionally, call Printer with "warn" and a List containing an appropriate message string". Maybe also "log an exception in the developer console given a JavaScript object e" which is "call Printer with "error" and a List containing e."

Then all the call sites could cross-link to these terms. It wouldn't be much different than today, but it would kind of emphasize that things all tie together---HTML's "developer console" and the console discussed in the Console Standard.

@Fishrock123
Copy link

I should note that true warnings are impossible for Node.js to implement. We only have two channels available, stdout and stderr as dictated by external factors.

Currently warnings in Node.js go to stderr.

@domenic
Copy link
Member

domenic commented Dec 19, 2016

Well, I'm not sure "impossible to implement" is quite the right term. You can implement the Printer however you please. E.g. you could prepend the logLevel before writing out the string, or use different colors, or whatever. (Or do nothing different between warn and error.) There's no requirement involving POSIX output streams in the spec.

@Fishrock123
Copy link

Right, I meant in the regard to having them be a) just the output that user provided, and b) differentiable.

Perhaps the spec does/will not require those points?

@domenic
Copy link
Member

domenic commented Dec 19, 2016

Yeah, if you read the spec I linked to, you can see no such requirements.

@domfarolino
Copy link
Member

This seems like a good idea and the more we reference vague hand-wavy warning-reporting things in the standard the more I want to do this. I propose we move forward with this by creating a report a console warning or report a developer console warning that both this specification and others can use. Callers of it can also use it optionally, such as: "optionally, report a developer console warning with the warning 'Blah blah blah'"

It should be an easy enough change that I'm happy to take on. Looks like it'll provide a good ROI when we and other specs want to handle warning-reporting things, especially if you do it a lot (this should keep things DRY).

@annevk
Copy link
Member Author

annevk commented May 25, 2018

We should probably leave the actual warning undefined. Instead the algorithm can say that it should be something appropriate and localized for the occasion. And it needs to be optional of course.

@domfarolino
Copy link
Member

Indeed, summarizing IRC: Callers can provide something generic (kinda like the warning we provide in time()), but don't have to provide anything. And as you said we should make it clear that:

  • The warning is purely advisory
  • May be subject to localization (so should probably be general)
  • In optional (if none is provided, this standard's algorithm could just display anything that indicates a warning)

@domfarolino
Copy link
Member

Ugh, finishing this off soon I promise, got blocked up with a bunch of stuff all at once.

@terinjokes
Copy link
Collaborator

@domfarolino How can I help?

@domfarolino
Copy link
Member

Will be requesting review soon on a small PR to take care of this, would be great to get feedback; in Seattle this week so things are a tad hectic.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants