System.Management.Pash.Implementation.ExecutionVisitor.FindMatchingTrapStatement C# (CSharp) Method

FindMatchingTrapStatement() private method

private FindMatchingTrapStatement ( ReadOnlyCollection trapStatements, Exception ex ) : System.Management.Automation.Language.TrapStatementAst
trapStatements ReadOnlyCollection
ex System.Exception
return System.Management.Automation.Language.TrapStatementAst
        private TrapStatementAst FindMatchingTrapStatement(ReadOnlyCollection<TrapStatementAst> trapStatements, Exception ex)
        {
            TrapStatementAst trapStatementAst = (from statement in trapStatements
                                                 where IsExactMatch(statement.TrapType, ex)
                                                 select statement).FirstOrDefault();
            if (trapStatementAst != null)
            {
                return trapStatementAst;
            }

            trapStatementAst = (from statement in trapStatements
                                where IsInheritedMatch(statement.TrapType, ex)
                                select statement).FirstOrDefault();

            if (trapStatementAst != null)
            {
                return trapStatementAst;
            }

            return (from statement in trapStatements
                    where statement.TrapType == null
                    select statement).FirstOrDefault();
        }
ExecutionVisitor