I've found a way of getting NS and IE to capture errors and allow me to display them in a more meaningful fashion.

I've added the following method to my dynapi.js:

    errors : [],
    displayerrors : true,

    errorHandler : function (msg, url, lno) {
        DynAPI.errors[DynAPI.errors.length] = [url,lno,msg];
        if (DynAPI.loaded&&DynAPI.displayerrors) alert("Error in '"+url+"'.\nLine number: "+lno+".\nMessage: "+msg);
        return true;
    },
    errorOutput : function () {
        errWindow=window.open('','','left=50,top=50,width=560,height=430');
        errWindow.document.writeln('<html><title>Have made an error!!!</title><B>Error Report</B><P>');
        errWindow.document.writeln('<table width=95%>');
        for (var i=0; i < DynAPI.errors.length; i++) {
            errWindow.document.write('<tr><td>');
            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>");
            if (DynAPI.errors[i][1]) errWindow.document.write("<B>Line number:</B> " + DynAPI.errors[i][1] + "<br>");
            if (DynAPI.errors[i][2]) errWindow.document.write("<B>Message:</B> <pre>" + DynAPI.errors[i][2] + "</pre>");
            errWindow.document.writeln('</td></tr>');
        };
        errWindow.document.writeln('</table>');
        errWindow.document.close();
    },

the following line has been added to the end of the loadhandler:

    if (DynAPI.errors.length&&DynAPI.displayerrors) DynAPI.errorOutput();

the following line has been added to the end of dynapi.js:

onerror = DynAPI.errorHandler;

this means that all the lines in the API that previosly used alerts to display errors can now use:
    DynAPI.errorHandler(null,null,"The following package could not be loaded: <b>"+src+"</b> \nMake sure you specified the correct path.");

--
Michael Pemberton
[EMAIL PROTECTED]
ICQ: 12107010
  _______________________________________________ Dynapi-Dev mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/dynapi-dev

Reply via email to