An exception that can be thrown by the associated method, along with a possibly empty list of postconditions that are true when that happens.
Inheritance: IThrownException
Example #1
0
 /// <summary>
 /// Get the mutable copy of a thrown exception.
 /// </summary>
 /// <param name="thrownException"></param>
 /// <returns></returns>
 public virtual ThrownException GetMutableCopy(IThrownException thrownException) {
   object cachedValue;
   if (this.cache.TryGetValue(thrownException, out cachedValue))
     return (ThrownException)cachedValue;
   var result = new ThrownException(thrownException);
   // Probably not necessary, no two thrown exceptions are shared. 
   this.cache.Add(thrownException, result);
   this.cache.Add(result, result);
   return result;
 }
Example #2
0
 /// <summary>
 /// Visits the specified thrown exception.
 /// </summary>
 /// <param name="thrownException">The thrown exception.</param>
 protected virtual IThrownException DeepCopy(ThrownException thrownException) {
   thrownException.ExceptionType = this.Substitute(thrownException.ExceptionType);
   thrownException.Postcondition = this.Substitute(thrownException.Postcondition);
   return thrownException;
 }
Example #3
0
 private static List<IThrownException> FilterUserMessage(IContractAwareHost host, IEnumerable<IThrownException> thrownExceptions, ITypeDefinition typeDefinition) {
   int n = (int)IteratorHelper.EnumerableCount(thrownExceptions);
   var filteredThrownExceptions = new IThrownException[n];
   var i = 0;
   foreach (var te in thrownExceptions) {
     if (CanAccess(te.Postcondition.Description, typeDefinition)) {
       filteredThrownExceptions[i] = te;
     } else {
       var newP = new Postcondition(te.Postcondition);
       newP.Description = null;
       filteredThrownExceptions[i] = new ThrownException() {
         ExceptionType = te.ExceptionType,
         Postcondition = newP,
       };
     }
     i++;
   }
   return new List<IThrownException>(filteredThrownExceptions);
 }