O'Reilly logo

Learning ASP.NET 2.0 with AJAX by Dan Hurwitz, Jesse Liberty, Brian MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Error Handling

You can and should avoid bugs, but there are runtime errors that cannot be avoided and should be handled as gracefully as possible. You would like to avoid having the end user see ugly or cryptic error messages, or worse, having the application crash. Errors can arise from any number of causes: user action, such as entering invalidly formatted text into a field, program logic errors, or circumstances entirely out of your control, such as an unavailable file or a downed network.

The simplest bugs to find and fix are syntax errors: violations of the rules of the language. For example, suppose you had the following line of code in your VB program:

	Dim i as Integr

When you compile the program, you will get a compiler error because the keyword to declare an integer is misspelled.

Using the IDE dramatically reduces your syntax errors. Depending on how the IDE is configured, any code element that isn't recognized is underlined. If Auto List Members is turned on (Tools → Options → Text Editor → All Languages), the incidence of syntax errors is further reduced. Check the "Show All Settings" checkbox (and leave it checked) to see these menu options.

If any syntax errors remain or if you are using a different editor, then any syntax errors will be caught by the compiler every time you build the project. It is very difficult for a syntax error to slip by into production code.

Tip

When the compiler finds a syntax error, an error message containing the location of the error and a terse ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required