Alex Rivera | Logout

It is possible to resume execution from the point where an exception was raised?

Asked 2012-02-08T10:43:54.963
9

There is an example which illustrates my question:

procedure Test;
begin
  try
    ShowMessage('1');
    raise EWarning.Create(12345, 'Warning: something is happens!');
    ShowMessage('2');
  except
    on E: EWarning do
      if IWantToContinue(E.ErrorCode) then
        E.SkipThisWarning // shows '1' then '2'
      else
        E.StopExecution;  // shows '1'
  end;
end;

function IWantToContinue(const ErrorCode: Integer): Boolean;
begin
  //...
end;

I tried to use something like this:

asm
  jmp ExceptAddr
end;

but it's wont' work...

Any ideas?

Thanks.

Edit
Report

1 Answer

0

BASICally, your code wont work because ExceptAddr is a function, not a variable. So, your code snippet changes as follows:

{$O-}
procedure TForm1.FormCreate(Sender: TObject);
begin
  try
    OutputDebugString('entering');
    raise Exception.Create('Error Message');
    OutputDebugString('leaving');
  except on E: Exception do
    begin
      OutputDebugString(PChar(Format('ExceptAddr = %p', [ExceptAddr])));
      asm
        CALL  ExceptAddr
        JMP   EAX
      end;
    end;
  end;
end;
answered 2012-02-08T11:32:18.897

Your Answer