Main Content

ssSetErrorStatus

Report an error

Syntax

void ssSetErrorStatus(SimStruct *S, const char_T *msg)

Arguments

S

SimStruct that represents an S-Function block or a Simulink® model.

msg

Error message.

Description

Use this function to report errors that occur in your S-function in a single-threaded application. For example:

ssSetErrorStatus(S, "error message");
return;

Note

The error message character vector must be in persistent memory; it cannot be a local variable. If you use sprintf to format the error message, you must allocate memory for the message. For example:

static char msg[35];
sprintf(msg,"Expected number of parameters: %d",ssGetNumSFcnParams(S));
ssSetErrorStatus(S,msg);

Calling ssSetErrorStatus does not cause the Simulink engine to stop and display the specified error message. ssSetErrorStatus call should be followed by a return statement to skip the rest of the function where ssSetErrorStatus resides. The function does not generate an exception. Thus, you can use it in your S-function to avoid creating exceptions when reporting errors.

Use this function to report errors in single-threaded applications or applications that must run on releases before R2019a. For multi-threaded applications, use ssSetLocalErrorStatus instead.

Languages

C, C++

Examples

See the S-function stvctf.c used in sfcndemo_stvctf.

Version History

Introduced before R2006a