Skip to Content
Beginning ASP.NET 3.5: In C# and VB
book

Beginning ASP.NET 3.5: In C# and VB

by Imar Spaanjaars
March 2008
Intermediate to advanced content levelIntermediate to advanced
766 pages
21h 15m
English
Wrox
Content preview from Beginning ASP.NET 3.5: In C# and VB

17.1. Exception Handling

Whenever you write code, there is a chance things won't turn out as expected, resulting in non-compatible code, a crash, or otherwise unexpected behavior of your application. Things can go wrong for a large number of reasons: you introduced a typo in your code, the database server you're connecting to at run time suddenly goes down, you got your logic mixed up and accidentally deleted all records from a database table instead of just one, you try to delete a record from a database table that still has associated records, you try to write a file to a folder without proper permissions, your users enter incorrect data, and so forth.

In order to understand these problems and think of ways to anticipate, avoid, and handle them, you first need to understand the different types of errors that may occur in your web application. Once you understand the main differences, the remainder of this section is spent discussing ways to prevent and solve them.

17.1.1. Different Types of Errors

You can broadly categorize errors into the following groups:

  • Syntax errors: Errors that are caused by typos or missing keywords, for example.

  • Logic errors: Errors in applications that seem to run fine but that produce unexpected or unwanted results.

  • Run-time errors: Errors that cause the application to crash or behave unexpectedly at run time.

Each of these categories is discussed in the following sections, together with information on avoiding and fixing them.

17.1.1.1. Syntax Errors ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning ASP.NET 4: in C# and VB

Beginning ASP.NET 4: in C# and VB

Imar Spaanjaars
Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Professional ASP.NET 3.5 SP1 Edition: In C# and VB

Bill Evjen, Scott Hanselman, Devin Rader

Publisher Resources

ISBN: 9780470187593Purchase book