1 Reply Latest reply on Nov 16, 2006 3:12 PM by michael_ramirez44

    Run-Time Errors cause wierdness

    michael_ramirez44 Level 1
      I have a remote object call that sends a query string to a database. I am trying to catch errors coming from the database because of bad sql statements. In my code there is an IF statements that checks if the first row returned is an object by trying to convert it to a string. If it is not equal to "[object Object]" then I know its an error message generated from the database. My problem is as soon as I uncomment the IF statement and test my app everything begins acting wierd as soon as my app hits that logic. Items highlight, tree controls show junk, etc. If I comment out the IF everything works fine but I get a alert for rows returned and one with the error message. I tried enclosing everything in a try catch but there seems to be no run-time error occuring. Has anybody else experience wierd things when errors occur?


      private function queryResults(event:ResultEvent):void
      {
      var call:Object = event.token;
      var isError:Boolean = false;

      if( call.state == "FillGrid" )
      {
      results = event.result as ArrayCollection;
      if( results.length == 1 )
      {

      var errMsg:String = results.getItemAt(0).toString();

      //if( errMsg != "[object Object]" )
      //{
      Alert.show(errMsg,"Error");
      //isError = true;
      //}

      }

      if( !isError)
      {
      results.filterFunction = searchData;
      Alert.show( results.length.toString() + " Rows Returned! ","Results");
      SortColumns();

      if( results.length > 0 )
      {
      calculateGrandTotals(results);
      }
      }
      }
      }
        • 1. Re: Run-Time Errors cause wierdness
          michael_ramirez44 Level 1
          I have adjusted some of the logic in my code and now it works fine. I would still like to know what was causing the wierd stuff.

          private function queryResults(event:ResultEvent):void
          {
          var call:Object = event.token;
          var isError:Boolean = false;
          var msg:String = "";
          var msgHeader:String = "Results";

          if( call.state == "FillGrid" )
          {
          var tmpResults:ArrayCollection = event.result as ArrayCollection;
          msg = tmpResults.length.toString() + " Rows Returned! ";
          if( tmpResults.length == 1 )
          {
          var errMsg:String = tmpResults.getItemAt(0).toString();
          if( errMsg != "[object Object]" )
          {
          msg = errMsg;
          msgHeader = "Error";
          isError = true;
          }
          }

          Alert.show( msg,msgHeader);
          if( isError == false )
          {
          results = tmpResults;
          results.filterFunction = searchData;
          SortColumns();

          if( results.length > 0 )
          {
          calculateGrandTotals(results);
          }
          }

          }
          }