Share via


BaseForm.ShowError(Exception, String, Boolean) Method

Definition

Displays the specified exception and information about the exception in a message box.

protected public:
 void ShowError(Exception ^ exception, System::String ^ message, bool isWarning);
protected internal void ShowError (Exception exception, string message, bool isWarning);
member this.ShowError : Exception * string * bool -> unit

Parameters

exception
Exception

The exception to display.

message
String

An error message.

isWarning
Boolean

true to display a warning symbol; false to display an error symbol.

Examples

The following example uses the ShowError method to display exception information.

protected override void DisplayErrorMessage(Exception ex,
    ResourceManager resourceManager) {
    string errorText = null;
    string errorMessage = null;

    ModuleServiceProxy.GetErrorInformation(ex,
        resourceManager, out errorText, out errorMessage);

    string errorString = String.Empty;

    if (String.IsNullOrEmpty(errorText)) {
        errorText = "Unknown Error Message";
        errorString = errorText + "Error Details \n"
            + errorMessage;
    } else {
        errorString = errorText;
    }

    ShowError(null, errorString, false);
}

Remarks

This method calls the GetService method to obtain a service object to display the error message.

Applies to