From: Michael P. <mp...@ph...> - 2001-01-18 05:33:12
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> I've found a way of getting NS and IE to capture errors and allow me to display them in a more meaningful fashion. <p>I've added the following method to my dynapi.js: <p><tt> errors : [],</tt> <br><tt> displayerrors : true,</tt> <p><tt> errorHandler : function (msg, url, lno) {</tt> <br><tt> DynAPI.errors[DynAPI.errors.length] = [url,lno,msg];</tt> <br><tt> if (DynAPI.loaded&&DynAPI.displayerrors) alert("Error in '"+url+"'.\nLine number: "+lno+".\nMessage: "+msg);</tt> <br><tt> return true;</tt> <br><tt> },</tt> <br><tt> errorOutput : function () {</tt> <br><tt> errWindow=window.open('','','left=50,top=50,width=560,height=430');</tt> <br><tt> errWindow.document.writeln('<html><title>Have made an error!!!</title><B>Error Report</B><P>');</tt> <br><tt> errWindow.document.writeln('<table width=95%>');</tt> <br><tt> for (var i=0; i < DynAPI.errors.length; i++) {</tt> <br><tt> errWindow.document.write('<tr><td>');</tt> <br><tt> if (DynAPI.errors[i][0]) errWindow.document.write("<B>Error in file:</B> <a href='"+DynAPI.errors[i][0]+ "'>" DynAPI.errors[i][0] + "</a><br>");</tt> <br><tt> if (DynAPI.errors[i][1]) errWindow.document.write("<B>Line number:</B> " + DynAPI.errors[i][1] + "<br>");</tt> <br><tt> if (DynAPI.errors[i][2]) errWindow.document.write("<B>Message:</B> <pre>" + DynAPI.errors[i][2] + "</pre>");</tt> <br><tt> errWindow.document.writeln('</td></tr>');</tt> <br><tt> };</tt> <br><tt> errWindow.document.writeln('</table>');</tt> <br><tt> errWindow.document.close();</tt> <br><tt> },</tt> <p>the following line has been added to the end of the loadhandler: <p><tt> if (DynAPI.errors.length&&DynAPI.displayerrors) DynAPI.errorOutput();</tt> <p>the following line has been added to the end of dynapi.js: <p>onerror = DynAPI.errorHandler; <p>this means that all the lines in the API that previosly used alerts to display errors can now use: <br><tt> DynAPI.errorHandler(null,null,"The following package could not be loaded: <b>"+src+"</b> \nMake sure you specified the correct path.");</tt> <p>-- <br>Michael Pemberton <br>mp...@ph... <br>ICQ: 12107010 <br> </html> |