Target Language Compiler | ![]() ![]() |
Error Reporting
You may need to detect and report error conditions in your TLC code. Error detection and reporting is needed most often in library functions. While rare, it is also possible to encounter error conditions in block target file code. The reason this is rare, but can occur if there is an unforeseen condition that the S-function mdlCheckParameters
function does not detect.
To report an error condition detected in you TLC code, use the LibBlockReportError
or LibBlockReportFatalError
utility functions. Use of these functions is fully documented in the Reference section. 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.
![]() | Loop Rolling | TLC Function Library Reference | ![]() |