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); }
public void Ctor_Message() { var exception = new ElementNotEnabledException("Message"); Assert.Equal("Message", exception.Message); Assert.Null(exception.InnerException); Assert.Equal(E_ELEMENTNOTENABLED, exception.HResult); }
public void Ctor_Message_InnerException() { var innerException = new Exception(); var exception = new ElementNotEnabledException("Message", innerException); Assert.Equal("Message", exception.Message); Assert.Same(innerException, exception.InnerException); Assert.Equal(E_ELEMENTNOTENABLED, exception.HResult); }
/// <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); }