Handling Errors in the HTML Page

[Previous] [Next]

Any control obtaining real-time data from a remote source must be prepared to deal with communication errors. As noted earlier, the Stock Ticker control sets the Internet Transfer control's RequestTimeout property to ensure that the HTTP request eventually returns. If the request times out, it passes the error information back to the web page through the NewData event. Let's look at how the HTML page handles the error condition:

 Sub StockTicker_NewData(fError, ErrText)     If fError Then         Dim nReponse         window.status = "Problems obtaining new stock information!"         nResponse = MsgBox("Unable to load new stock information " & _             "because..." & _             vbCrLf & vbCrLf & ErrText & vbCrLf & vbCrLf & _             "Would you like to work off line with simulated data?", _             vbYesNo + vbCritical)         If nResponse = vbYes Then             rbOffline_onClick         End If     Else         window.status = "Completed loading new stock data."     End If End Sub 'StockTicker_NewData() 

The Stock Ticker control itself does not display error information in a message box. This is intentional because you should always pass error information up to the highest user interface level possible, allowing that level to display the error. In this case, the higher user interface level is the web page.

The web page's NewData event handler checks the error flag, and if True, it sets the browser's status bar to indicate that an error has occurred and displays the error text returned from the Stock Ticker control in a message box. It wraps a question around the error text, asking the user if he or she wants to work off line instead. If the user responds with a "yes," the code sets the Stock Ticker control's SimulatedData property to True by calling the Click event handler of the Simulate Data radio button. If the error flag was False, the code simply updates the status bar to reflect a successful fetching of new data.



Programming Microsoft Office 2000 Web Components
Programming Microsoft Office 2000 Web Components (Microsoft Progamming Series)
ISBN: 073560794X
EAN: 2147483647
Year: 1999
Pages: 111
Authors: Dave Stearns

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net