Check for lineNumber support before using it
Paul O’Shannessy committed
Dec 22, 2014 at 13:37 UTC
f0f431e4282fd542c4cfdc74d820c52b2b64187b
1 file changed
+8
-1
vendor/browser-transforms.js
+8
-1
@@ -82,6 +82,13 @@ function exec(source, options) {
82
*/
83
function createSourceCodeErrorMessage(code, e) {
84
var sourceLines = code.split('\n');
85
+ // e.lineNumber is non-standard so we can't depend on its availability. If
86
+ // we're in a browser where it isn't supported, don't even bother trying to
87
+ // format anything. We may also hit a case where the line number is reported
88
+ // incorrectly and is outside the bounds of the actual code. Handle that too.
89
+ if (!e.lineNumber || e.lineNumber > sourceLines.length) {
90
+ return '';
91
+ }
92
var erroneousLine = sourceLines[e.lineNumber - 1];
93
94
// Removes any leading indenting spaces and gets the number of
@@ -130,7 +137,7 @@ function transformCode(code, url, options) {
137
// The error will correctly point to `url` in Firefox.
138
e.fileName = url;
139
}
133
- e.message += url + ':' + e.lineNumber + ':' + e.column;
140
+ e.message += url + ':' + e.lineNumber + ':' + e.columnNumber;
141
} else {
142
e.message += location.href;
143
}