我试图找到我们的所有法典,在新例外被推翻后不再包含原始例外作为内部例外的情况下,再保留例外。 例如:
catch(DBApplicationException dbEx)
{
BaseApplicationException bEx = new BaseApplicationException(dbEx.Message, dbEx);
bEx.MethodName = System.Reflection.Assembly.GetExecutingAssembly().FullName + "::" + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString();
bEx.Severity = ExceptionSeverityLevel;
PublishingManager.Publish(bEx,"");
throw bEx;
}
catch(Exception e)
{
BaseApplicationException bEx = new BaseApplicationException(e.Message);
bEx.MethodName = System.Reflection.Assembly.GetExecutingAssembly().FullName + "::" + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString();
bEx.Severity = ExceptionSeverityLevel;
PublishingManager.Publish(bEx,"");
throw bEx;
}
第一批渔获(副渔获物(DBApplicationException dbEx)被重新thrown为“基地应用接收器”,但正如你所看到的那样,它把电文称作“Ex.Message”,然后具体指明了“Inner Exception”为“dbEx”,但第二个排入部分是“无内接受”的,它只包含“e.Message”。
因此,就我的ex鱼模式而言,我只想找到一只不包含内脏例外的渔获区,现在,使用这两个集水区的收益的Im型号。
这里,我的做法如下:
catch((.|
|
)*){((.|
|
)*)Exception(((?!,).)+);((.|
|
)*)}
这里我用来检验这一设想的方法:
public static DataSet SearchUserSessions(string username, string first, string last, string startDate, string endDate)
{
DataSet ds = null;
try
{
SqlParameter [] arParms = new SqlParameter[]
{
new SqlParameter("@UserName", username),
new SqlParameter("@FirstName", first),
new SqlParameter("@LastName", last),
new SqlParameter("@SessionStart", startDate),
new SqlParameter("@SessionEnd", endDate)
};
DB db = new DB();
ds = db.ExecuteDataset(SecurityConfig.ConnectionString, CommandType.StoredProcedure,
SPSearchUserSessions, (DB.Provider)SecurityConfig.ConnectionProviderType,
arParms);
}
catch(DBApplicationException dbEx)
{
BaseApplicationException bEx = new BaseApplicationException(dbEx.Message, dbEx);
bEx.MethodName = System.Reflection.Assembly.GetExecutingAssembly().FullName + "::" + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString();
bEx.Severity = ExceptionSeverityLevel;
PublishingManager.Publish(bEx,"");
throw bEx;
}
catch(Exception e)
{
BaseApplicationException bEx = new BaseApplicationException(e.Message);
bEx.MethodName = System.Reflection.Assembly.GetExecutingAssembly().FullName + "::" + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString();
bEx.Severity = ExceptionSeverityLevel;
PublishingManager.Publish(bEx,"");
throw bEx;
}
return ds;
}