Unusual Error Catching Behaviour

D

DamienS

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top