Whenever there some sort of failure DWR calls an error or warning handler (depending on the severity of the error) and passes it the message.
This method could be used to display error messages in an alert box or to the status bar.
To change the global error handler use dwr.engine.setErrorHandler(function)
, and to change the global warning handler use dwr.engine.setWarningHandler(function)
. Please note that the error and warning handlers can also be set on a per call basis using the call meta-data options:
Remote.method(params, { callback:function(data) { alert("it worked"); }, errorHandler:function(message) { alert("it broke"); } });
For more information about handling errors and warnings, see the error handling page.
DWREngine.setTimeout() and the call and batch level call meta-data options allow you to set a timeout values. The global DWREngine.setTimeout() function does it for all DWR calls. A value of 0 (the default) turns call timeouts off.
The units passed to setTimeout() are milli-seconds. If a call timeout happens, the the appropriate error handler is called.
Example of setting a timeout on a call level:
Remote.method(params, { callback:function(data) { alert("it worked"); }, errorHandler:function(message) { alert("it broke"); }, timeout:1000 });
If Remote.method()
takes more then 1 second to execute, the "it broke" message will be displayed.