Open
Bug 1257918
Opened 9 years ago
Updated 4 months ago
Error in Web Console reports the wrong line number
Categories
(DevTools :: Console, defect, P2)
Tracking
(Not tracked)
NEW
People
(Reporter: peterbe, Unassigned)
References
(Blocks 1 open bug, )
Details
Attachments
(1 file)
153 bytes,
text/html
|
Details |
I wrote this code: https://gist.github.com/peterbe/8ff51943f3f62441fffe
There's an interval callback that executes function `checkStatus`. And if that one fails (it does an ajax promise thing), it cancels the interval.
But there's a bug in my code. The bug is that the `checkStatus()` function didn't return the promise. I.e. the `.fail(...)` would be executed on the output of `checkStatus()` which is, I believe, undefined.
The real problem is the error message::
TypeError: checkStatus(...) is undefined
I had to use Chrome to understand my mistake. I thought I had misspelled "checkStatus" and triple-checked that. And I had to check the scoping rules but as you can see, they should be in the same scope.
The error message Chrome gives is better::
Uncaught TypeError: Cannot read property 'fail' of undefined
In Firefox, it said the error was on line 14. In Chrome it was on line 15.
Reporter | ||
Comment 1•9 years ago
|
||
Open this in Firefox and open your web console. It complains about checkStatus() and not about my AFTER-use of the result of checkStatus().
http://codepen.io/peterbe/pen/yOgrdm?editors=0011
Reporter | ||
Updated•9 years ago
|
Comment 2•9 years ago
|
||
Moving this to the console component.
Component: Developer Tools: Debugger → Developer Tools: Console
Comment 3•9 years ago
|
||
Reduced test case
Comment 4•9 years ago
|
||
Morgan, this seems semi-related to to JS error message work you are doing.
If you open: https://bug1257918.bmoattachments.org/attachment.cgi?id=8734759:
The error we are emitting is `TypeError: checkStatus(...) is undefined` (line 6).
And here's what Chrome is emitting: `Uncaught TypeError: Cannot read property 'fail' of undefined` (line 7)
I think pointing to line 7 in this case is more useful, since the call to checkStatus() didn't throw but rather the error is happening once trying to call fail(). Also including the name of the function it was trying to call (`fail`) is useful. Without deciding on exact wording, do you think we'd be able to modify the message to include these things (the updated line number and the name of the property it was trying to access)?
Flags: needinfo?(winter2718)
Comment 5•9 years ago
|
||
(In reply to Brian Grinstead [:bgrins] from comment #4)
> Morgan, this seems semi-related to to JS error message work you are doing.
>
> If you open: https://bug1257918.bmoattachments.org/attachment.cgi?id=8734759:
>
> The error we are emitting is `TypeError: checkStatus(...) is undefined`
> (line 6).
> And here's what Chrome is emitting: `Uncaught TypeError: Cannot read
> property 'fail' of undefined` (line 7)
>
> I think pointing to line 7 in this case is more useful, since the call to
> checkStatus() didn't throw but rather the error is happening once trying to
> call fail(). Also including the name of the function it was trying to call
> (`fail`) is useful. Without deciding on exact wording, do you think we'd be
> able to modify the message to include these things (the updated line number
> and the name of the property it was trying to access)?
I agree that we can and should improve the error message for attempted property access of undefined. I'll create another bug.
Flags: needinfo?(winter2718)
Comment 6•8 years ago
|
||
Second that. I have a similar case here:
Firefox - "TypeError: e is undefined"
Chrome - "Uncaught TypeError: Cannot set property 'amplify' of undefined"
Comment 7•8 years ago
|
||
Btw, I minified my JS when getting this error also running it through babel. If I switch Babel off, it gets even less meaningful:
"TypeError: (intermediate value)(...) is not a function"
Still the same msg in Chrome as above
Comment 8•8 years ago
|
||
Sorry for the bug spam, in the second example JS seems to have been cached in Chrome. Without Babel it actually gives the same error as Firefox "Uncaught TypeError: (intermediate value)(...) is not a function"
can't delete my previous comment, #7 and #8 could be hidden I guess
Updated•7 years ago
|
Product: Firefox → DevTools
Updated•7 years ago
|
Priority: -- → P2
Comment 9•6 years ago
|
||
The error message is now "TypeError: checkStatus(...) is undefined; can't access its "fail" property" which I think solve one part of the issue.
Let's keep this bug for the line number.
Summary: Confusing TypeError error in Web Console → Error in Web Console reports the wrong line number
Updated•2 years ago
|
Severity: normal → S3
Updated•4 months ago
|
Blocks: dt-2025-h1-P2
You need to log in
before you can comment on or make changes to this bug.
Description
•