There are four main types of errors that you will encounter at some point in time.
Four main types of errors:
1. Configuration errors - Errors that are caused by problems that are found in the web.config or the machine.config files.
2. Parser errors - The cause of this type of error is incorrect syntax in an ASP.Net page.
3. Compilation errors - This error is fired via the compiler.
4. Runtime errors - This error is fired at page execution.
The term you will grow to love is simply called exception handling and what this means is anything that happens in your application that is unexpected or undesired.
Properties of the exception class:
1. StackTrace - Gets a string representation of the frames on the call stack at the time the current exception was thrown.
2. InnerException - Gets the exception instance that caused the current exception.
3. Message - Gets a message that describes the current exception.
4. HelpLink - Gets or sets a link to the help file associated with this exception.
5. Source - Gets or sets the name of the application or the object that causes the error.
6. TargetSite - Gets the method that throws the current exception.
7. HResult - Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.
Be sure to examine the exception class.
Quick Example Catch
Whenever you execute a statement that has the potential to fail; you will want to wrap the statement in a try…catch block. This way you can handle any runtime errors that may result from the statement.
To start off with catches, you have use try....catch….finally syntax. It looks like this:
// some part of the coding whereupon it might fail at runtime
catch (Exception e)
// block of code that does error handling
// coding that will run no matter what happens before this point
Now that you have the general knowledge of the types of errors that you may encounter and a basic example of the try...catch... finally syntax it is time to move on to a more in depth discussion.