// CatchBlock private CatchBlock Rewrite(CatchBlock node) { Statement body = RewriteStatement(node.Body); if ((object)body != (object)node.Body) { return(Ast.Catch(node.Span, node.Header, node.Test, node.Variable, body)); } else { return(node); } }
public TryStatementBuilder Filter(Type type, Variable holder, Expression condition, Statement body) { if (_skipNext) { _skipNext = false; return(this); } Contract.RequiresNotNull(type, "type"); Contract.RequiresNotNull(condition, "condition"); Contract.RequiresNotNull(holder, "holder"); Contract.RequiresNotNull(body, "body"); if (_catchBlocks == null) { _catchBlocks = new List <CatchBlock>(); } _catchBlocks.Add(Ast.Catch(type, holder, Ast.IfThenElse(condition, body, Ast.Rethrow()))); return(this); }
public TryStatementBuilder Catch(Type type, Variable holder, Statement body) { if (_skipNext) { _skipNext = false; return(this); } Contract.RequiresNotNull(type, "type"); Contract.RequiresNotNull(body, "body"); if (_finallyStatement != null) { throw new InvalidOperationException("Finally statement already defined"); } if (_catchBlocks == null) { _catchBlocks = new List <CatchBlock>(); } _catchBlocks.Add(Ast.Catch(type, holder, body)); return(this); }