public override void BeginCatchBlock(Type exceptionType)
{
if (exceptionType == null)
throw new ArgumentNullException("exceptionType");
if (this.activeExceptionRegions == null || this.activeExceptionRegions.Count == 0)
throw new InvalidOperationException("BeginExceptionBlock() must have been called before calling this method.");
// Get a token for the exception type.
var exceptionTypeToken = this.GetToken(exceptionType);
// Get the top-most exception region.
var exceptionRegion = this.activeExceptionRegions.Peek();
// Check there isn't already a catch block with the same type.
foreach (var clause in exceptionRegion.Clauses)
if (clause.Type == ExceptionClauseType.Catch && clause.CatchToken == exceptionTypeToken)
throw new InvalidOperationException("Multiple catch clauses with the same type are not allowed.");
// Close off the current exception clause.
EndCurrentClause(exceptionRegion);
// Add a new finally clause.
exceptionRegion.Clauses.Add(new ExceptionClause() { Type = ExceptionClauseType.Catch, ILStart = this.offset, CatchToken = exceptionTypeToken });
// The evaluation stack starts with the exception on the top of the stack.
ReplaceEvaluationStack(VESType.Object);
}