only fetch .errors file for script load errors (#1636)
diff --git a/lib/src/dartdevc/dartdevc.dart b/lib/src/dartdevc/dartdevc.dart
index e887aaf..417d1e6 100644
--- a/lib/src/dartdevc/dartdevc.dart
+++ b/lib/src/dartdevc/dartdevc.dart
@@ -185,14 +185,16 @@
(function() {
var oldOnError = requirejs.onError;
requirejs.onError = function(e) {
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- console.error(this.responseText);
- }
- };
- xhr.open("GET", e.originalError.srcElement.src + ".errors", true);
- xhr.send();
+ if (e.originalError && e.originalError.srcElement) {
+ var xhr = new XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+ console.error(this.responseText);
+ }
+ };
+ xhr.open("GET", e.originalError.srcElement.src + ".errors", true);
+ xhr.send();
+ }
// Also handle errors the normal way.
if (oldOnError) oldOnError(e);
};