showErrorDialog¶
- utils.dlgs.showErrorDialog(ParentFigure, err, winTitle, optionalPrefix, optionalSuffix, options)¶
SHOWERRORDIALOG - Show an error dialog generated in try/catch blocks or any other occasion.
- Syntax:
function showErrorDialog(ParentFigure, err, winTitle, optionalPrefix, optionalSuffix, options)
Supports custom icons, HTML formatting, scrollable error text, clipboard copy button, and is resizable.
- Input Arguments:
ParentFigure - handle to the parent window (AppContainer, uifigure, or []) When empty or a legacy GUIDE figure, falls back to errordlg(). In MIB pass
obj.mibModel.getProgressBarParent()so the dialog follows the active dataset window when it is undocked.err - error source, one of:
[char|string] plain error message text
[MException] struct with fields:
.identifier- error identifier string.message- error message.cause- nestedMExceptioncell array
empty struct: shows only prefix/suffix
winTitle - [optional] string with dialog window title (default:
'Error')optionalPrefix - [optional] text shown in bold above the error body (default:
'')optionalSuffix - [optional] text shown in italics below the error body (default:
'')options (optional) - struct with fields:
.mibPath- [char] path to MIB installation for icon loading (default:'').Icon- [char] icon name (default:'puffin_error'):'puffin_error','puffin_warning','puffin_question','warning_48px','error_48px','question_48px','celebrate','call4help'.IconWidth- [numeric] icon column width in pixels (default: 48, puffins: 96).WindowWidth- [numeric] dialog width in pixels (default: 420).WindowHeight- [numeric] dialog height in pixels (default: 220).WindowStyle- [char]'modal'(default) or'normal'.PrefixHeight- row height for the prefix label (default:'fit').ErrorHeight- row height for the error text area (default:'1x').SuffixHeight- row height for the suffix label (default:'fit')
- Output Arguments:
(none)
- Usage:
Example 1 - Basic usage in try/catch
try % some code catch err utils.dlgs.showErrorDialog(obj.view.gui, err, 'Processing Error', 'prefix'); return; endExample 2 - Plain text with bold prefix and italic suffix
utils.dlgs.showErrorDialog(obj.view.gui, 'Something went wrong!', 'Error', ... 'Operation failed:', 'Please check your input.');Example 3 - Custom icon, size, and row heights
opts.mibPath = obj.mibModel.mibPath; opts.Icon = 'puffin_warning'; opts.WindowWidth = 500; opts.WindowHeight = 300; opts.PrefixHeight = 'fit'; opts.ErrorHeight = '1x'; opts.SuffixHeight = 'fit'; utils.dlgs.showErrorDialog(obj.view.gui, err, 'Import Error', ... 'Failed to load file:', 'Please contact support.', opts);