Unusual Error Catching Behaviour

Discussion in 'ASP .Net' started by DamienS, Dec 3, 2008.

  1. DamienS

    DamienS Guest

    Hello all,

    I'm wondering if someone could help me with an interesting error
    issue.

    I have a global error catch routine implmented as a HTTP module
    triggered on the httpApplication.Error event.

    We have a situtation in a production system where, at various times of
    the day, other applications hammer the SQL server (batch accounts
    processing etc). At this time, the asp.net site is throwing SQL
    timeout errors. I currently have the timeout set to 60 seconds which
    should be heaps, what's more, I'm pretty sure that the queries
    (usually in sprocs) of the website are farily well optmised with
    indexes etc.

    Anyway - i decided to set up an error handler around the failing
    execute to try and determine which queries are failing so that they
    can be further examined (show yourselves damnit!!!)

    The issue is though that for some reason it appears to not be
    processing my custom error - instead just returning the generic error.
    I have no idea why this is. It should be entering my catch.

    Can anyone see something obvious that I'm missing?

    Thanks in advance,


    Damien




    public static string[] GetEIDsFromSQL(.......
    [trunked]....List<SqlParameter> sQLParams)
    {
    ........[trunked]....
    using (SqlConnection con =
    root.GlobalFunctions.oSQLConnection)
    {
    SqlCommand cmdQuery = new SqlCommand
    (sQLLoadString, con);
    cmdQuery.CommandType =
    CommandType.StoredProcedure;
    .......[trunked (added parameters etc)]....

    try
    {

    /////// ********** ON FAILURE THIS ERROR
    IS (WRONGLY) HANDLED *********
    oDT.Load(cmdQuery.ExecuteReader());
    }
    catch (Exception ex)
    {
    string Params = "";
    sQLParams.ToList().ForEach(x =>
    {
    Params += (string.Format("***
    Field:{0} Value:{1}", x.ParameterName, x.Value));
    });
    /////// ********** THIS IS THE ERROR THAT
    I WANT HANDLED... BUT IT DOESN'T FIRE*********
    throw new Exception(string.Format("Data
    access error. SQLString={0}. Params = {1}",
    sQLLoadString,
    Params),ex);
    }
    }
    ........[trunked]....
    }

    }




    If it helps, this is the error that I'm getting. I was hoping that it
    would have additional information embedded in it.

    System.Data.SqlClient.SqlException: Timeout expired. The timeout
    period elapsed prior to completion of the operation or the server is
    not responding.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException
    exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
    exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning
    (TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
    SqlCommand cmdHandler, SqlDataReader dataStream,
    BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
    stateObj)
    at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
    at System.Data.SqlClient.SqlDataReader.get_MetaData()
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader
    (SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds
    (CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean
    returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader
    (CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean
    returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader
    (CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean
    returnStream, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
    behavior, String method)
    at System.Data.SqlClient.SqlCommand.ExecuteReader()
    at RPM.clsGlobalStaticFunctions.GetEIDsFromSQL(clsRPMRoot root,
    String sQLLoadString, CommandType commandType, List`1 sQLParams) in c:
    \Local My Documents\Code\\\RPM\Classes\RemedyForms
    \clsGlobalStaticFunctions.cs:line 116
    DamienS, Dec 3, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas Hawkins

    Unusual ServerSocket Behaviour

    Thomas Hawkins, Jan 28, 2004, in forum: Java
    Replies:
    3
    Views:
    474
    Steve Horsley
    Jan 30, 2004
  2. Replies:
    3
    Views:
    313
  3. Robert Rawlins

    RE: Unusual Exception Behaviour

    Robert Rawlins, Jul 18, 2008, in forum: Python
    Replies:
    3
    Views:
    239
    Vinay Sajip
    Jul 20, 2008
  4. Yogi

    unusual rake behaviour

    Yogi, Dec 29, 2004, in forum: Ruby
    Replies:
    12
    Views:
    192
    Jim Weirich
    Jan 3, 2005
  5. Ken Tuck

    unusual behaviour

    Ken Tuck, Oct 22, 2003, in forum: Javascript
    Replies:
    2
    Views:
    81
    Richard Cornford
    Oct 22, 2003
Loading...

Share This Page