How does Delphis exception handling work?
Submitted by: AdministratorThe basic structure goes something like this:
p := new(big_thing);
try
blah(p);
foo(p);
finally
dispose(p);
end;
The first line allocates a big block of memory. Then, in the "try" block, we execute several statements, each of which might produce an error--or, in other words, "raise an event." If an error does occur, the rest of the "try" block will be skipped, "finally" blocks will be executed. If there are no errors, then the "finally" block will be entered when the last statement in the "try" block completes. So, either way, the big block of memory gets freed. These "try/finally" blocks will trap anything up to and including a Windows GPF.
Submitted by: Administrator
p := new(big_thing);
try
blah(p);
foo(p);
finally
dispose(p);
end;
The first line allocates a big block of memory. Then, in the "try" block, we execute several statements, each of which might produce an error--or, in other words, "raise an event." If an error does occur, the rest of the "try" block will be skipped, "finally" blocks will be executed. If there are no errors, then the "finally" block will be entered when the last statement in the "try" block completes. So, either way, the big block of memory gets freed. These "try/finally" blocks will trap anything up to and including a Windows GPF.
Submitted by: Administrator
Read Online Delphi Job Interview Questions And Answers
Top Delphi Questions
☺ | What is Delphi? |
☺ | How does Delphi handle Windows callbacks? |
☺ | How do I close a modal form? For that matter, what is the best way to close any form? |
☺ | How tough is it to learn Delphi? |
☺ | What should I give to Windows API functions that want a hWnd? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |