IManagementUIService.ShowError(Exception, String, String, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Displays the specified exception and information about the exception in a message box.
public:
void ShowError(Exception ^ exception, System::String ^ message, System::String ^ caption, bool isWarning);
public void ShowError (Exception exception, string message, string caption, bool isWarning);
abstract member ShowError : Exception * string * string * bool -> unit
Parameters
- message
- String
A message to display that provides information about the exception.
- caption
- String
The caption for the message box.
- isWarning
- Boolean
true
if the error message is to be considered a warning; otherwise, false
.
Examples
The following example implements this method.
private IWin32Window DialogOwner {
get {
return _curWin.Peek();
}
}
void IManagementUIService.ShowError(
Exception exception,
string message,
string caption,
bool isWarning) {
string text = message;
if (exception != null) {
if (!String.IsNullOrEmpty(text)) {
text += Environment.NewLine + Environment.NewLine;
}
text += exception.Message;
}
MessageBoxIcon icon = isWarning ? MessageBoxIcon.Warning : MessageBoxIcon.Error;
ShowMessage(DialogOwner,
_owner.Title, // member var init in MyUI_Srvc ctor
caption,
text,
icon, // Warning | Error
MessageBoxButtons.OK,
MessageBoxDefaultButton.Button1);
}
internal DialogResult ShowMessage(
IWin32Window owner,
string appTitle,
string caption, string text,
MessageBoxIcon icon,
MessageBoxButtons buttons,
MessageBoxDefaultButton defaultButton) {
if (String.IsNullOrEmpty(caption)) {
caption = appTitle;
}
MessageBoxOptions options = (MessageBoxOptions)0;
if ((owner is Control && owner != null &&
((Control)owner).RightToLeft == RightToLeft.Yes) ||
_rightToLeft) {
options |= MessageBoxOptions.RtlReading |
MessageBoxOptions.RightAlign;
}
return MessageBox.Show(owner, text, caption,
buttons, icon, defaultButton, options);
}