Đang chuẩn bị liên kết để tải về tài liệu:
Giáo trình Exception Handling
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
An exception is termed as an abnormal condition encountered by an application during execution. Exception handling is the process of providing an alternative path of execution when the application is unable to execute as desired. This chapter describes exceptions. It explains how to implement the try, catch, and finally blocks. In addition, it also discusses the implementation of user-defined exceptions. | Exception Handling An exception is termed as an abnormal condition encountered by an application during execution. Exception handling is the process of providing an alternative path of execution when the application is unable to execute as desired. This chapter describes exceptions. It explains how to implement the try catch and finally blocks. In addition it also discusses the implementation of user-defined exceptions. Objectives Chapter 10 In this chapter you will learn to fl Describe exceptions fl Handle exceptions fl Implement the user-defined exceptions Describing Exceptions An exception is an erroneous situation that occurs during program execution. Exceptional situations arise when an operation cannot be completed normally. When an exception occurs in an application the system throws an error. The error is handled through the process of exception handling. For example the System.io. lOException error is thrown when you try to access an illegal stream object. Similarly if the denominator is zero an integer division operation throws the System.DivideByZeroException error. Whenever an error occurs runtime creates an exception object and sends it to the program in which the exception occurred. This action is known as throwing an exception. The exception object contains information about the type of error. Types of Errors There are three types of errors that can occur in the application. These are Syntax errors Run-time errors Logical errors A syntax error occurs when compiler cannot compile code. Such an error can occur when statements are not constructed properly keywords are misspelled or punctuation is omitted. At compilation time all the statements in the application get connected with each other to make a single executable unit. A run-time error occurs when an application attempts to perform an operation which is not allowed at runtime. An example of such an error is division by zero. A run-time error is also termed as an exception. All the exceptions are .