本文整理匯總了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);
}