Re: Try Finally...

From: VBDis (vbdis_at_aol.com)
Date: 10/28/04


Date: 28 Oct 2004 07:59:09 GMT

Im Artikel <i8dtn0lmc1pag4olh3dtjv71ovadk0op78@4ax.com>, "Martin Harvey (Demon
account)" <martin@nospam_pergolesi.demon.co.uk> schreibt:

>>The Retry idea was (is?) to re-run the code in the TRY section of a
try/except
>>block... If you fixed the problem, why not give it another shot?

>Yes, but this is typically to fix problems like page faults.

In BASIC a RESUME or RESUME NEXT was commonly used practice, in times before
SEH. It may have it's place even in SEH, perhaps as a replacement for many
small code sections of the pattern:

retries := MaxRetryCount;
while retries > 0 do begin
  try SomethingCritical; goto succ;
  except TryRepair; dec(retries);
  end;
end;
{if retries <= 0 then} SignalUnrecoverableError;
succ: ...

or

try try TryThis except {don't worry} end finally WhatEverRequried end;

But I'm not sure whether Delphi reports the line (code address) and stack state
in the /current/ procedure, containing the code that caused an exception
somewhere down in the call stack. Resuming at the place where the exception
occured doesn't make much sense, since the parameters that caused the exception
(div/0, overflow...) can be modified only when the exception handler has direct
access to these variables. Resuming in the current procedure, i.e. in the try
block with the according exception handler, could make sense, but is feasable
only with appropriate support by the compiler and RTS. This is how the BASIC
exception handling works, sometimes pretty nice to implement, but sometimes
very hard to code with regards to checking for explicit line numbers (where the
error occured) and error conditions.

Laura, do you have a concrete idea how to implement a Retry feature in Delphi?

DoDi



Relevant Pages

  • Re: Exclusive Writes to a file.
    ... > an exception gets thrown. ... Best is to do retries with a randomized interval. ... you are going to write in a memory block and transfer the complete block in ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question for Randy or Frank
    ... This is an HLA standard library facility. ... >> that you won't get under Windows. ... Then there's the "exception handling" approach to errors (which the HLA ... rather than solely "one big exception handler" wrapping the entire program ...
    (alt.lang.asm)
  • Re: Structured Exception Handling (was: Try Finally...)
    ... >> exception handlers and termination handlers. ... >> exception filtering, except clauses, and finally clauses, is up to ... > exception handler related to the stopping exception filter. ...
    (comp.lang.pascal.delphi.misc)
  • StackWalk behaviour
    ... I am adding an exception handler to certain of our build configurations ... actually dump the callstack for each thread. ... the second and third seemed to result in a valid callstack. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Practical error/exception handling...
    ... > try-except blocks until they reach the exception handler that really ... > If you have a catch-all exception handler, ... > the stack to the next exception handler. ... Raptor squirms in seat, ...
    (alt.comp.lang.borland-delphi)