Exemplo n.º 1
0
        internal static bool ConvertException(System.Runtime.InteropServices.COMException e, out Exception uiaException)
        {
            bool handled = true;

            switch (e.ErrorCode)
            {
            case UiaCoreIds.UIA_E_ELEMENTNOTAVAILABLE:
                uiaException = new ElementNotAvailableException(e);
                break;

            case UiaCoreIds.UIA_E_ELEMENTNOTENABLED:
                uiaException = new ElementNotEnabledException(e);
                break;

            case UiaCoreIds.UIA_E_NOCLICKABLEPOINT:
                uiaException = new NoClickablePointException(e);
                break;

            case UiaCoreIds.UIA_E_PROXYASSEMBLYNOTLOADED:
                uiaException = new ProxyAssemblyNotLoadedException(e);
                break;

            default:
                uiaException = null;
                handled      = false;
                break;
            }
            return(handled);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tries to convert a com exception to a more usable exception.
        /// </summary>
        public static bool ConvertException(System.Runtime.InteropServices.COMException ex, out Exception uiaException)
        {
            var handled = true;

            switch ((uint)ex.ErrorCode)
            {
            case UIA_E_ELEMENTNOTENABLED:
                uiaException = new ElementNotEnabledException(ex);
                break;

            case UIA_E_ELEMENTNOTAVAILABLE:
                uiaException = new ElementNotAvailableException(ex);
                break;

            case UIA_E_NOCLICKABLEPOINT:
                uiaException = new NoClickablePointException(ex);
                break;

            case UIA_E_PROXYASSEMBLYNOTLOADED:
                uiaException = new ProxyAssemblyNotLoadedException(ex);
                break;

            case UIA_E_TIMEOUT:
                uiaException = new TimeoutException("UIA Timeout", ex);
                break;

            case UIA_E_NOTSUPPORTED:
                uiaException = new Exceptions.NotSupportedException(ex);
                break;

            case UIA_E_INVALIDOPERATION:
                uiaException = new InvalidOperationException("UIA Invalid Operation", ex);
                break;

            default:
                uiaException = null;
                handled      = false;
                break;
            }
            return(handled);
        }