ErrorOccurred Event
(Not recommended) Notify when device-related errors occur
This session object function is not recommended. Use DataAcquisition
object functions instead. See Version History.
Syntax
Description
lh = addlistener(
creates a listener for the session,'ErrorOccurred',callbackfct);ErrorOccurred event. When an error occurs, the
callback is executed. The callback can be any MATLAB® function with the (src,event) signature.
Note
In background mode, errors and exceptions are not displayed by default. Use the
ErrorOccurred event listener to display the errors.
lh = addlistener( creates a listener for the
session,'ErrorOccurred',@(src,event)
expr);ErrorOccurred event and fires an anonymous function. The anonymous function
requires the specified input arguments and executes the operation specified in the expression
expr. Anonymous functions provide a quick means of creating simple functions
without requiring that your function be saved in a separate file. For more information, see
Anonymous Functions.
The callback has two required parameters: src and
event. src is the session object for the listener, and
event is a daq.ErrorOccurredInfo object. The
daq.ErrorOccurredInfo object contains the Error
property, which is the MException associated with the error. You can use the
getReport method to return a formatted message that uses the same format as errors
thrown by internal MATLAB code.