I will close out this thread with a little more explanation and describe the solution I'm using.
I need to be able to differentiate between a "critical" Oracle error (can't access data, DB down, bad password, etc) and data related errors (constraint issue). The key is whether data can be accessed, if it can't I consider that "critical".
Now, in a situation where I was coding the data layer I would catch "critical" errors when creating the Connection to Oracle. I would catch other areas executing queries against the database.
LLBLGen handles connection creation and query execution in one line of from the developer's perspective like this:
DataSet dataSet = RetrievalProcedures.ByNationalIdentifier(nationalIdentifier);
So I can't catch a Connection error, if an Exception occurs the line above returns the OracleException, but I can't determine the context of when the exception occured (either on connection or on query execution).
So, how do I determine if there is a Critical Oracle Exception? I have to check the OracleException.Number against a known list of critical errors (1017 - bad name or password, 12154 - TNS server name not found, those sort of things), and if it is one of those I throw a custom CriticalOracleException which I can handle in a custom manner.
Here's the function I'm using to make this determination. LoadCriticalOracleErrorList loads a list of errors from a text file (can't put it on the DB...) using a StreamReader.
This solution works fine and it's what we are implementing in our Proxy and Service components to handle OracleExceptions coming out of our generated Oracle code.
public static Exception HandleOracleException(OracleException e, string source)
{
List<int> CriticalOracleErrors = LoadCriticalOracleErrorList();
if (CriticalOracleErrors.Contains(e.Number))
{
CoreIntegration.HandleException(e, TraceEventType.Critical);
throw new CriticalOracleException(string.Format("Critical Oracle Error in '{0}', the eWarp is probably not functioning at this time (the Oracle error is '{1}')",source, e.Message), e);
}
else
{
CoreIntegration.HandleException(e, TraceEventType.Error);
throw e;
}
}
Thanks,
Jason