【发布时间】:2021-09-10 07:15:16
【问题描述】:
我有错误类:
public class FailureException<TRequest, TResponse> : PartialFailureException<TRequest, TResponse>
{
public FailureException(TRequest request, TResponse response, TRequest requestToRetry)
: base(request, response, requestToRetry) { }
}
然后我有不同的类来检测错误的类型:
public static class ErrorDetector
{
public static bool IsFailure(Exception e) =>
e.GetType() == typeof(FailureException<TRequest, TResponse>));
}
是否可以在不添加FailureException<TRequest, TResponse>(仅使用FailureException)的情况下检查错误类型,这样我就不需要将
【问题讨论】:
-
this 会回答您的问题吗?只需将
List<>替换为FailureException<,>。
标签: c# asp.net-core exception .net-core