src/Misc/EFTools/DesignXmlCore/Common/CriticalException.cs
/// <summary>
///     Shows non-critical exceptions to the user and returns false or
///     returns true for critical exceptions.
/// </summary>
/// <param name="serviceProvider">Service provider to use to display error message.</param>
/// <param name="ex">Exception to handle.</param>
/// <returns>True if exception is critical and can't be ignored.</returns>
Shows non-critical exceptions to the user and returns false or
returns true for critical exceptions.
Shows non - critical exceptions to the user and returns false or returns true for critical exceptions .
internal static bool ThrowOrShow(IServiceProvider serviceProvider, Exception ex)
        {
            if (IsCriticalException(ex))
            {
                return true;
            }
            if (serviceProvider != null)
            {
                var uiService = serviceProvider.GetService(typeof(IUIService)) as IUIService;
                if (uiService != null)
                {
                    uiService.ShowError(ex);
                    return false;
                }
            }
            Debug.Fail("unable to get IUIService.  Falling back on MessageBox.Show()");
            MessageBoxOptions options = 0;
            if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
            {
                options = MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading;
            }
            MessageBox.Show(
                null, ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1,
                options);
            return false;
        }
internal static bool ThrowOrShow ( IServiceProvider serviceProvider , Exception ex ) { if ( IsCriticalException ( ex ) ) { return true ; } if ( serviceProvider != null ) { var uiService = serviceProvider . GetService ( typeof ( IUIService ) ) as IUIService ; if ( uiService != null ) { uiService . ShowError ( ex ) ; return false ; } } Debug . Fail ( " " ) ; MessageBoxOptions options = 0 ; if ( CultureInfo . CurrentUICulture . TextInfo . IsRightToLeft ) { options = MessageBoxOptions . RightAlign | MessageBoxOptions . RtlReading ; } MessageBox . Show ( null , ex . Message , ex . GetType ( ) . Name , MessageBoxButtons . OK , MessageBoxIcon . Exclamation , MessageBoxDefaultButton . Button1 , options ) ; return false ; }
Shows non-critical exceptions to the user and returns false or
returns true for critical exceptions.
Shows non - critical exceptions to the user and returns false or returns true for critical exceptions .
True if exception is critical and can't be ignored.
True if exception is critical and can ' t be ignored .
serviceProvider
IServiceProvider
Service provider to use to display error message.
Service provider to use to display error message .
ex
Exception
Exception to handle.
Exception to handle .