Open
Bug 1353067
Opened 9 years ago
Updated 3 years ago
Improve "is not a non-null object" message
Categories
(Core :: JavaScript Engine, defect, P3)
Core
JavaScript Engine
Tracking
()
NEW
People
(Reporter: fs, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-needed, triage-deferred)
Attachments
(1 file)
|
1.69 KB,
patch
|
arai
:
feedback+
|
Details | Diff | Splinter Review |
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_non-null_object (which needs updating, if we update our message)
At least for me, "x is not a non-null object" is kind of hard to understand.
Case 1: Object.defineProperty({}, 'key', 1);
Firefox: TypeError: 1 is not a non-null object
Chrome: Uncaught TypeError: Property description must be an object: 1
Chrome makes more sense and actually tells you that the property description object is what is missing here.
Case 2: new WeakSet().add('foo');
Firefox: TypeError: "foo" is not a non-null object
Chrome: Uncaught TypeError: Invalid value used in weak set
Chrome isn't too helpful here either.
Maybe "TypeError: WeakSet value must be an object, got a string"
There might be more cases, search for JSMSG_NOT_NONNULL_OBJECT.
I think in general, "must be x, but got y" is most helpful. We have such error messages elsewhere.
Updated•8 years ago
|
Keywords: triage-deferred
Priority: -- → P3
Comment 1•8 years ago
|
||
Change error message of case1.
case2 is already solved.
https://bugzilla.mozilla.org/show_bug.cgi?id=7747
Now, the error message is below.
```
js> Object.defineProperty({},'key',1);
typein:1:1 TypeError: ({}) is not a non-null object
```
descriptor must be object.
In this patch, the error message is below.
```
js> Object.defineProperty({},'key',1);
typein:1:1 TypeError: descriptor must be an object, got number '1'
```
the grammer is "{0} must be an object, got {1} '{2}'", and when you use defineProperty, {0} is "descriptor" ,{1} is the type of descriptor, and {2} is the descripter which you write down literely.
Attachment #8925808 -
Flags: review?(arai.unmht)
Comment 2•8 years ago
|
||
sorry, I mistook the URL
https://bugzilla.mozilla.org/show_bug.cgi?id=774744
Comment 3•8 years ago
|
||
Comment on attachment 8925808 [details] [diff] [review]
bug1353067.patch
Review of attachment 8925808 [details] [diff] [review]:
-----------------------------------------------------------------
Thank you for your patch.
The change itself looks good.
Then, since there are several more places [1] that uses JSMSG_NOT_NONNULL_OBJECT,
it would be nice to file dedicated bug for this single fix.
can you file a bug for this and attach this patch there?
[1] https://dxr.mozilla.org/mozilla-central/search?q=JSMSG_NOT_NONNULL_OBJECT&case=true&=mozilla-central
Attachment #8925808 -
Flags: review?(arai.unmht) → feedback+
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•