title: Catching JS errors on file include
body: <p>is there any handler to catch an error when including / loading a js file?</p>
  
  <p>I am looping through an array and appending a the scripts into my head.
  is there any way I can see if the included JS file has an error ( ergo then I could get rid of the include sequence headaches, just looping through an array of js files that didnt load 5 or so times or evenby grabbing the files that gave errors, maybe handling  them, figuring out why they broke, then including them again)</p>
  
  <pre><code>var incFile=[
  "Grid.EditGrid"
  ,"Data.AutoSaveStore"
  ,"Form.FormPanel"   
  ,"ux.Spotlight"
  ];
  
  
  //http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
  //This can be extended to include css files aswell
  
  //Dynamic Js file loading                               
  loadJsFile = function(filename){
      var fileref=document.createElement('script');
      fileref.setAttribute("src", "js"+filename);
      fileref.setAttribute("language","javascript");  
      document.getElementsByTagName("head")[0].appendChild(fileref);  
  };
  
  
  //The loop to include java files
  for (var f=0;f&lt;=incFile.length-1;f++){
  var path = "";
  var split = incFile[f].split(".");
  //Build the relative path
  for(var s=0;s&lt;=split.length-1;s++){
      path +=  "/"+split[s];
  };  
    loadJsFile(path+".js");
  };
  </code></pre>