我正在使用帶有自定義異常的Agatha框架。我有一個例外,MyException
,這我指定爲BusinessExceptionType
當我配置我的要求:使用Agatha框架進行異常處理(BusinessExceptionType)
new ServiceLayerConfiguration(Assembly.GetExecutingAssembly(), typeof(SomeRequestResponse.MakeARequest).Assembly, typeof(Container)) { BusinessExceptionType = typeof(MyException) }.Initialize();
這是怎麼了拋出該異常:但是
throw new MyException(message);
當異常被拋出, ,MyException
未被識別爲BusinessExceptionType
。我如何才能將其識別爲BusinessExceptionType
?以下情況並非如此。
if (response.ExceptionType == ExceptionType.Business)
這裏是異常類:
public class MyException : Exception
{
public MyException()
{
}
public MyException(string message) : base(message)
{
}
public MyException(string message, Exception inner) : base(message, inner)
{
}
protected MyException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
UPDATE: 它出現在BusinessExceptionType
在serviceLayerConfiguration
設置正確,直到我把我的第一個請求時,BusinessExceptionType
變得null
。在配置請求和提出我的第一個請求之間的某個地方,它變成了null
。要麼,要麼在RequestProcessor.cs
中抓取不同的serviceLayerConfiguration
。任何幫助,這是表示讚賞。