コード例 #1
0
        internal static ExceptionHandlerNode GetHandler(
            ReadOnlyCollection <ExceptionHandlerNode> handlers,
            Exception exception,
            ExecutionContext context)
        {
            ExceptionTypeList.Comparer comparer1 = new ExceptionTypeList.Comparer(ExceptionTypeList.CompareEqual);
            Type matchedType = (Type)null;

            foreach (ExceptionHandlerNode handler in handlers)
            {
                if (handler.ExceptionTypes != null && handler.ExceptionTypes.Matches(comparer1, exception.GetType(), out matchedType))
                {
                    ScriptTrace.Trace(context, 1, "TrapOnExceptionMatch", (object)exception.GetType());
                    return(handler);
                }
            }
            ExceptionTypeList.Comparer comparer2 = new ExceptionTypeList.Comparer(ExceptionTypeList.CompareSubclass);
            foreach (ExceptionHandlerNode handler in handlers)
            {
                if (handler.ExceptionTypes != null && handler.ExceptionTypes.Matches(comparer2, exception.GetType(), out matchedType))
                {
                    ScriptTrace.Trace(context, 1, "TrapOnSubclassMatch", (object)matchedType, (object)exception.GetType());
                    return(handler);
                }
            }
            foreach (ExceptionHandlerNode handler in handlers)
            {
                if (handler.ExceptionTypes == null)
                {
                    ScriptTrace.Trace(context, 1, "TrapOnGenericException", (object)exception.GetType());
                    return(handler);
                }
            }
            return((ExceptionHandlerNode)null);
        }
コード例 #2
0
 internal bool Matches(ExceptionTypeList.Comparer comparer, Type type, out Type matchedType)
 {
     matchedType = (Type)null;
     foreach (TypeLiteral typeLiteral in (Collection <TypeLiteral>) this)
     {
         if (comparer(type, typeLiteral.Type))
         {
             matchedType = typeLiteral.Type;
             return(true);
         }
     }
     return(false);
 }