Chapter 10

Performing Error Handling

In This Chapter

arrow Defining the nature of errors

arrow Catching errors in your code

arrow Telling others about errors

No one likes errors. However, errors happen. In many cases, you don’t even have to do anything wrong to see an error in your code. For example, a user could supply a value that simply doesn’t work with the application, or a network error could cause problems. Someone could choose to move a site, or a vendor could change the level of support in a browser. In fact, all sorts of issues can confront the JavaScript developer.

Fortunately, it’s also possible to do something about errors. You can use a three-step process to make errors less frightening:

1. You need to know more about the nature of errors. Knowing what causes errors in the first place can help you avoid them. Previous chapters in this book provide some examples of how you can avoid errors by doing things like checking the input type of data and validating that the data range falls within the limits you expected.

2. After you come to understand errors better, you need to know how to catch them, which means intercepting them before they become a problem. After you catch the error, ...

Get HTML5 Programming with JavaScript For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.