Friday 15 April 2011

exception handling - C#/Java "Try/Finally/Catch" equivalent construct in Delphi -



exception handling - C#/Java "Try/Finally/Catch" equivalent construct in Delphi -

in delphi, how can utilize try, finally, , grab together? java/c# equivalent like:

try { // open db connection, start transaction } grab (exception e) { // roll db transaction } { // close db connection, commit transaction }

if seek in delphi, can either utilize try/finally or try/except; never 3 together. code next (which doesn't compile):

try // open db connection, start transaction except on e: exception begin // roll transaction end // compiler error: expected "end" not "finally" begin // commit transaction end

in delphi can utilize next pattern:

// initialize / allocate resource (create objects etc.) ... seek seek // utilize resource ... except // handle exception ... end; // free resource / cleanup ... end

delphi exception-handling

No comments:

Post a Comment