Error Reporting

You might need to detect and report error conditions in your TLC code. Error detection and reporting are needed most often in library functions. While rare, it is also possible to encounter error conditions in block target file code if there is an unforeseen condition that the S-function mdlCheckParameters function does not detect.

To report an error condition detected in your TLC code, use the LibBlockReportError or LibBlockReportFatalError utility functions. Here is an example of using LibBlockReportError in the paramlib.tlc function LibBlockParameter to report the condition of an improper use of that function:

%if TYPE(param.Value) == "Matrix"
    %% exit if the parameter is a true matrix,
    %% i.e., has more than one row or columns.
    %if nRows > 1
      %assign errTxt = "Must access parameter %<param.Name> using "...
        "LibBlockMatrixParameter."
      %<LibBlockReportError([], errTxt)>
    %endif
  %endif

Browse through matlabroot/rtw/c/tlc for more examples of the use of LibBlockReportError. Also, read further details in TLC Error Handling, which describes types of TLC errors and their interpretations.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS