| 296 | | throw new Error("Could not load '" + moduleName + "'; last tried '" + relpath + "'"); |
| | 297 | |
| | 298 | if( !this._parsingBadFile ){ // Errors pass through here twice. Only allow once |
| | 299 | |
| | 300 | this._parsingBadFile = true; |
| | 301 | var _lastLoaded = this._loadedUrls[this._loadedUrls.length-1]; |
| | 302 | var _badFile = relpath.split("/")[relpath.split("/").length-1]; |
| | 303 | |
| | 304 | // Checking if the last file attempted to load is also the last file loaded. |
| | 305 | // In other words, this script block only cares about syntax errors. If it |
| | 306 | // was a file-not-found, that error needs to skip this and pass down to the |
| | 307 | // 'throw' below. |
| | 308 | // |
| | 309 | if(_lastLoaded.indexOf(_badFile)){ |
| | 310 | |
| | 311 | // In the event of a script error, dynamically create a script tag and |
| | 312 | // load suspect script into it. The script can then be evaluated directly |
| | 313 | // by the Javascript debugger and gives an accurate pointer to location of |
| | 314 | // the problem, and a general description of the incorrect syntax. |
| | 315 | // Yes, this even works in IE. |
| | 316 | // |
| | 317 | var scr = document.createElement("script"); |
| | 318 | scr.src = _lastLoaded; |
| | 319 | document.getElementsByTagName("head")[0].appendChild(scr); |
| | 320 | |
| | 321 | // Stop the thread here, and don't go through to the error throw below. |
| | 322 | // It's inaccurate for syntax errors anyway. It causes a double error, |
| | 323 | // and the 'throw' is first, with a misleading pointer to this script. |
| | 324 | // |
| | 325 | return; |
| | 326 | } |
| | 327 | } |
| | 328 | // |
| | 329 | throw new Error("Could not load '" + moduleName + "'; last tried: '" + relpath + "'"); |