Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə186/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   182   183   184   185   186   187   188   189   ...   294
DelphiLanguageGuide

Declaring Exception Types
Exception types are declared just like other classes. In fact, it is possible to use an instance of any class as an
exception, but it is recommended that exceptions be derived from the Exception class defined in 
SysUtils
.
You can group exceptions into families using inheritance. For example, the following declarations in 
SysUtils
define a family of exception types for math errors.
type 
   EMathError = class(Exception); 
   EInvalidOp = class(EMathError); 
   EZeroDivide = class(EMathError);  
   EOverflow = class(EMathError); 
   EUnderflow = class(EMathError);
Given these declarations, you can define a single EMathError exception handler that also handles EInvalidOp,
EZeroDivide, EOverflow, and EUnderflow.
Exception classes sometimes define fields, methods, or properties that convey additional information about the error.
For example,
type EInOutError = class(Exception)  
       ErrorCode: Integer;
     end;

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   182   183   184   185   186   187   188   189   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin