我正在使用带有自定义异常的Agatha框架。我有一个例外,我在配置我的请求MyException
时将其指定为: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)
{
}
}
更新:
似乎BusinessExceptionType
设置serviceLayerConfiguration
正确,直到我在BusinessExceptionType
成为null
. 在配置请求和发出我的第一个请求之间的某个地方,它变成了null
. 要么,要么它serviceLayerConfiguration
在RequestProcessor.cs
. 对此的任何帮助表示赞赏。