HTML and CSS Reference
Now that we have detected errors, the next step is deciding what to do with them. It is im-
portant that you, as the application programmer, understand that these errors have occurred.
Unlike with a server however, there is no centralized log file containing all the errors that
In the case of exceptions, the requirements should specify what to do if an exception occurs.
For instance, if an AJAX call cannot be performed:
Should the user be informed?
Should we try to carry on the best we can without the data from the AJAX call?
Should we prevent the user performing any other actions on the web page?
The answers to these questions depend on the requirements. Detecting the exception is the
first step, but detection cannot help you determine what should be done with the exception.
When an error is detected there is not usually anything that can be done except document the
fact that the error has occurred. Due to the fact that errors are unanticipated, they should not
be handled by the code, but unless you document the fact they have occurred it is unlikely
you will ever notice that they have occurred, since you cannot see a log of the users console.
My preferred approach for handling errors is to log them with the log4js library. A link to
ling errors, which may include sending them to the server via AJAX so that they can be
logged in a centralized file.