Is there a way to further simplify the following?

I need to make the exception message more indicative of the context of the error and I hope to combine the 2
try blocks into one.

It seems possible in Java and C# but not in FPC.
Is there a way to combine them like

  try

  except

  finally

  end;

Dennis

------------
Obj := TSomeObject.Create;
TheContext := 'after object creation';
try
  try
    TheContext := 'Before doing task 1';
     //task 1

   TheContext := 'Before doing task 2';
   //task 2

   TheContext := 'Before doing task 3';
  //task 3
  finally
    FreeAndNil(Obj);
  end;

except
  On E : Exception do begin
     E.Message := TheContext+E.Message ;
    raise;
  end;
end;
-------------
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to