Skip to main content
Participating Frequently
April 16, 2011
Question

Exceptions not being caught

  • April 16, 2011
  • 2 replies
  • 336 views

I am having a problem with exceptions not being caught

even though I am catching "any" exception.

I am querying millions of records from a table.

After 20 min, unexpectedly, my script jumps to the

finally() block and ends the script.

I'm not sure whether the query returned with an exception

which didn't get caught, or whether the script itself timed out,

and went directly to finally() to end the script.

Here is basically what I'm doing:

//=====================================

// queryData()

//=====================================

public void function queryData() {

try {

   FileWriteLine(myfile, "Executing query");

   myquery = new query();

   myquery.execute(.....);

   FileWriteLine(myfile, "Got data");

} catch (any ex) {

   FileWriteLine(myfile, "Query failed");

   rethrow;

}

}

//=====================================

// main()

//=====================================

try {

   FileWriteLine(myfile, "Before queryData()");

   queryData();

   FileWriteLine(myfile, "After queryData()");

} catch (any ex) {

   FileWriteLine(myfile, "FAILED");

} finally {

   FileWriteLine(myfile, "DONE");

}

//=====================================

My output file (myfile) contains (which shouldn't be possible):

Before queryData()

Executing query

DONE

If it had succeeded, myfile should have:

Before queryData()

Executing query

Got data

After queryData()

DONE

If it had failed, myfile should have:

Before queryData()

Executing query

Query failed

FAILED

DONE

Does anyone know what might be going wrong?

Thanks.

myscreenname0345

    This topic has been closed for replies.

    2 replies

    Inspiring
    April 17, 2011

    This is all a bit odd, yes.  Whilst troubleshooting, remove all the try/catches and see if you do actually get an error along the way.

    What happens if you use CFQUERY rather than the somewhat jerry-built CFC-based wrapper implementation of same.

    --

    Adam

    Inspiring
    April 16, 2011

    I think the redundant try/catch blocks are messing you up.  Try it with just one.