1. Trang chủ
  2. » Công Nghệ Thông Tin

Chapter 4. Exception Handling pdf

10 242 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 130 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

your code or in code you call such as a shared library, unavailable operating system common language runtime encounters such as code that cannot be verified, and so on... Introduction ob

Trang 1

Chapter 4 Exception Handling

Hoàng Hữu Việt

IT Faculty, Vinh University

A reference of MSDN Library for Visual

Studio 2005

Trang 2

Contents

Trang 3

Slide 3

Introduction

unexpected behavior encountered by an executing program

your code or in code you call (such as a shared library), unavailable operating system

common language runtime encounters (such

as code that cannot be verified), and so on

Trang 4

Introduction

object that inherits from the Exception Class

class An exception is thrown from an area of code where a problem has occurred The exception is passed up the stack until the application handles it or the program terminates

Trang 5

Slide 5

Exception Class

which exceptions inherit Most exception

objects are instances of some derived class of

Exception, but you can throw any object

that derives from the Object class as an exception

Trang 6

Exception Class

Message: Provides details about the cause of an

exception.

StackTrace: Contains a stack trace that can be

used to determine where an error occurred The stack trace includes the source file name and program line number if debugging information is available

Trang 7

Slide 7

Try statement

together is to obtain and use resources in a

circumstances in a catch block, and release the resources in the finally block

Trang 8

try statement

try

{

1 Include codes in which exceptions might occur.

}

{

2 Represent types of exceptions the catch can handle }

finally

{

3.(Optional) codes present here will always execute }

Trang 9

Slide 9

Example

Error Message Error Message

Trang 10

Example

{

}

{

Ngày đăng: 02/08/2014, 18:21

TỪ KHÓA LIÊN QUAN