Closed Bug 873684 Opened 7 years ago Closed 7 years ago

WebIDL: Improve error reporting when we expect a Sequence or a Date and a value that is not an object is passed

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: reuben, Assigned: reuben)

Details

Attachments

(1 file)

Right now we report "TypeError: Value not an object", not very helpful. We really should be saying that the value is not a sequence/date/interface/etc.
This reports "Value does not implement interface Foo" instead of "Value not an object" for Dates, Sequences and objects within Sequences.
Assignee: nobody → reuben.bmo
Attachment #751262 - Flags: review?(bzbarsky)
How hard would it be to include file and line number in these error messages?
Hmm.  I guess "not an object" is more informative than just "not a Node" or whatnot in the sense that it tells you that you're not even in the right ballpark, but does make it hard to tell which argument is involved...

As for line and file, those should be present in the exception already, no?  Certainly I see them in the web console when I test one of these exceptions being thrown.
Comment on attachment 751262 [details] [diff] [review]
Improve error reporting

r=me.  Thank you!
Attachment #751262 - Flags: review?(bzbarsky) → review+
Actually, given these changes, would you mind changing the actual message for MSG_NOT_SEQUENCE to "Value can not be converted to a sequence", so as not to imply that we have an object?  Or we could have different messages for the "know is an object and it's not a sequence" (which will say "Object can not...") and "it's not even an object" (which will say "Value can not....").  Maybe it doesn't matter too much in practice and it's fine to just always have it say "Value can not ...".
https://hg.mozilla.org/mozilla-central/rev/17a16c7e9870
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.