Chapter 11. Error Handling


It seems that every language has its own way of reporting error conditions. Take for example VBScript, which uses the error object (Err). To trap errors in VBScript, you use the On Error Resume Next function. Contrast that to the way that Windows, the operating system, reports error conditions. When you call one of the API functions, normally the function returns an error code as its output parameter. Depending on what function you call, the code may return 0 if the function was successful or a negative number if it was unsuccessful. However, other functions return 0 if the function was unsuccessful and a positive number if the function was successful. What Microsoft tried to do was unify the way that every language reports errors. They did this by adding exception handling to the .NET Framework (the underlying platform that every language uses). Exceptions are objects that report error conditions. Because C# is built on top of the .NET Framework, it has instructions for catching and throwing exceptions, as well as for allowing you to define your own exceptions. (Developers often refer to generating an exception as throwing the exception.)



C#
C# & VB.NET Conversion Pocket Reference
ISBN: 0596003196
EAN: 2147483647
Year: 2003
Pages: 198
Authors: Jose Mojica

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net