Catching an error and Tossing an include

Results 1 to 2 of 2

Thread: Catching an error and Tossing an include

  1. #1
    Join Date
    Dec 1969

    Default Catching an error and Tossing an include

    I&#039;ve read the article about not being able to do conditional includes (<BR><BR>I&#039;ve been using the following (with favorable reults) to display my errors:<BR>try {<BR>**var oRS = ConnDB.Execute(strSQL);<BR>}<BR>catch(e) {<BR>**&#060;!--#include file="include/" --&#062;<BR>}<BR><BR>Would it be better if I did it this way instead:<BR>try {<BR>&nbsp;&nbsp;var oRS = ConnDB.Execute(strSQL);<BR>}<BR>catch(e) {<BR>**Response.Write(throwError("/include/"));<BR>}<BR><BR>function throwError(pti) {<BR>**var ForReading = 1;<BR>**var oFS = new ActiveXObject("Scripting.FileSystemObject");<BR>* *var oFL = oFS.OpenTextFile(Server.MapPath(pti), ForReading);<BR><BR>**return(oFL.ReadAll());<BR> }

  2. #2
    Join Date
    Dec 1969

    Default No...#include way better.

    But even better would be to do:<BR><BR>... at the very top of your ASP page: ...<BR>&#060;!-- #include file="include/" --&#062;<BR><BR>and then do:<BR><BR>...<BR>catch(e) {<BR> Response.Write( throwError["connExecuteError"] );<BR>}<BR><BR>And your "include/" file looks like this:<BR><BR>&#060;%<BR>var throwError = new Array();<BR>throwError["connConnectError"] = "Failure on attempt to make connection to DB";<BR>throwError["connExecuteError"] = "Failure on attempt to execute SQL statement";<BR>... etc. ...<BR>%&#062;<BR><BR>Take advantage of the face that JS arrays are associative!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts