Main Content

sldiagviewer.reportError

Report error messages in Diagnostic Viewer

Description

sldiagviewer.reportError(Message) reports the diagnostic message as an error in the Diagnostic Viewer.

output = sldiagviewer.reportError(Message) returns a logical 1 (true) when the diagnostic message reports successfully in the Diagnostic Viewer. Otherwise, an error message is displayed in the command window and no value is returned.

example

output = sldiagviewer.reportError(__,Component=ComponentNameValue) specifies the name of the component or product that generates the diagnostic message.

Examples

collapse all

Display error messages in the Diagnostic Viewer using sldiagviewer.reportError.

Load the model DiagnosticDemo.

model = "DiagnosticDemo";
load_system(model);

Create a stage to display the diagnostic messages.

myStage = sldiagviewer.createStage("Analysis","ModelName",model);

Introduce errors inside the try block and catch the resulting errors in the catch block.

try 
 i = p; 
catch error 
end 

Report the error message in the Diagnostic Viewer.

output = sldiagviewer.reportError(error)

The diagnostic window opens for the model and displays the error message in red in the Analysis stage.

Input Arguments

collapse all

Description of error that is displayed in the Diagnostic Viewer, specified as a string, MSLException object, or MException object.

Example: Unrecognized function or variable 'p'.

Name of the component or product that generates the diagnostic message, specified as a character vector or string.

Example: "Stateflow"

Example: "Simulink"

Data Types: string | char

Version History

Introduced in R2014a