Skip to content

What is a good error message? #7

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

Open
codehag opened this issue Oct 17, 2018 · 1 comment
Open

What is a good error message? #7

codehag opened this issue Oct 17, 2018 · 1 comment

Comments

@codehag
Copy link
Owner

codehag commented Oct 17, 2018

This is a general discussion issue to get some conversation on the topic, not an error message itself.

I am wondering how we would define a good error message. I have a couple of ideas:

  • relationship to the source code - a good error message would clearly show its relationship to the source code as it was written.

  • Error in relation to intended code - sometimes it is hard to tell exactly what the programmers intent was, but the closer the error message is to the intention, the more useful it is.

  • suggestions on how to fix - maybe we can give tips on where the problem is likely coming from?

Those are some initial thoughts. Let me know what you folks think.

Do you agree to license your suggested error message under an MIT-style license?

Yes

@parzhitsky
Copy link

Any error in JavaScript can be boiled down to an assumption of the program being broken in a critical way:

  • in nullish reference errors, the assumption is that the value's properties can be dereferenced (nullish values are the only ones for which this isn't the case);
  • in syntax errors, the input is assumed to be a source code parseable under the syntax rules;
  • in type errors, the value type is assumed to be assignable to a certain given one; etc.

An error message should include this information. When this is occasionally done, it is usually done with a phrase like expected <one thing>, instead got <another thing>.

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

No branches or pull requests

2 participants