Delphi exception handling

xiaoxiao2021-03-06  37

Try

Try

......

Except

... exception handling

END;

Finally

Release resource

END;

They can only be nested with each other, and they cannot be arranged together like Java.

In addition, the abnormality processing between Try ... Except ... End can be like this

Try

Strtoint ('a');

Except

ON E: Exception DO

Begin

Errstr: = E.MESSAGE;

Application.MessageBox (Pchar (Errstr), 'error', MB_ICONWARNING

END;

END;

Exception in the above method is to capture all exceptions, or use other specific types to capture specific types of exceptions, such as

Try

{Integer operation}

Except

ON EregEerror DO

{Ground processing}

ON EinTerror DO

{Other integer abnormal processing}

Else {other abnormal processing} END; specific detailed processing also carefully studied, these are basically enough in small applications

转载请注明原文地址:https://www.9cbs.com/read-66161.html

New Post(0)