views:

19

answers:

1

This is not necessarily a Flex-specific question, but I'll use Flex in my example:

Scenario: We have a fairly complex MVC Flex application that uses remoting and makes several asynchronous calls on a single page. Some of the calls are:

  • GetUserOrders
  • GetCurrentOrder
  • GetUserDetails

If there is a network or DB error, this will throw three separate error messages to the user and require three "OK" clicks. We are considering collecting all errors messages in a singleton array and displaying as a list in a common error message box.

What are best practices around gracefully handle multiple asynchronous errors on a single page--specifically when we need to alert users that there was an error?

A: 

For network or DB errors, you might consider writing some code that catches those and just displays a status message rather than a series of alerts.

From the user's perspective, if the network or DB hit an error, they'll want to know when it's okay to start clicking again. If you expect these errors to only occur in rare situations, an alert seems okay. However, if it's possible the network or DB might be down for a while and therefore they'd get a lot of these messages, I'd put a status message somewhere and the status message says that the network or DB is down until it is able to complete a request successfully. I'd imagine you could continue allowing the user to click and maybe even pinging your server every few seconds until a request works. Once it does, you could clear the status message and everything would continue normally. Hopefully that makes sense.

JavaScript code snippet:

if (response.error) {
    if (response.error === 'some type') {
        showStatusMessage('Network/DB down');
        startPollingNetworkDBStatus();
    } else {
        // Additional error handling...
    }
}
Bialecki