本文整理汇总了C#中System.Exception.FirstInner方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.FirstInner方法的具体用法?C# Exception.FirstInner怎么用?C# Exception.FirstInner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.FirstInner方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FirstInner_IsOfSameType_SameExceptionReturned
public void FirstInner_IsOfSameType_SameExceptionReturned()
{
Exception e = new Exception();
var actual = e.FirstInner<Exception>();
Assert.Same(e, actual);
}
示例2: FirstInner_DoesNotHaveInnerException_ReturnsNull
public void FirstInner_DoesNotHaveInnerException_ReturnsNull()
{
Exception e = new Exception();
Exception actual = e.FirstInner<ArgumentException>();
Assert.Null(actual);
}
示例3: Handle
public void Handle(Exception exception)
{
var concurrencyException = exception.FirstInner<OptimisticConcurrencyException>();
if (concurrencyException != null)
{
throw new ConcurrencyRepositoryViolationException(concurrencyException);
}
successor.Handle(exception);
}
示例4: FirstInner_InheritedExceptionFirstInner_InheritedExceptionReturned
public void FirstInner_InheritedExceptionFirstInner_InheritedExceptionReturned()
{
ArgumentException ae = new ArgumentException();
ArgumentNullException ane = new ArgumentNullException("", ae);
Exception e = new Exception("", ane);
ArgumentException actual = e.FirstInner<ArgumentException>();
Assert.Same(ane, actual);
}
示例5: Handle
public void Handle(Exception exception)
{
var updateException = exception.FirstInner<UpdateException>();
if (updateException != null)
{
throw new RepositoryUpdateException(updateException);
}
successor.Handle(exception);
}
示例6: Handle
public void Handle(Exception exception)
{
var validationException = exception.FirstInner<DbEntityValidationException>();
if (validationException != null)
{
IEnumerable<DataValidationResult> errors = GetErrors(validationException);
throw new DataValidationException(validationException.Message, errors, validationException);
}
successor.Handle(exception);
}
示例7: Handle
public void Handle(Exception exception)
{
var sqlException = exception.FirstInner<SqlException>();
if (sqlException != null)
{
switch (sqlException.Number)
{
case 242:
throw new DateTimeRangeRepositoryViolationException(sqlException);
case 547:
throw new DeleteConstraintRepositoryViolationException(sqlException);
case 1205:
throw new DeadlockVictimRepositoryViolationException(sqlException);
case 2601:
case 2627:
throw new UniqueConstraintRepositoryViolationException(sqlException);
default:
throw new RepositoryViolationException(sqlException);
}
}
successor.Handle(exception);
}