All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.delphi.rules.community-delphi.ReRaiseException.html Maven / Gradle / Ivy

There is a newer version: 1.12.1
Show newest version

Why is this an issue?

Re-raising a caught exception explicitly (i.e. passing the exception as an argument) causes a double free, as Delphi does not know that the re-raised exception is the original one and frees it at the end of the exception handler.

In these situations, a bare raise should be used. This correctly indicates that the current exception should be re-raised.

How to fix it

Replace the raise X statement with a simple raise:

try
  DoSomething;
except
  on E: Exception do begin
    Log.Debug('Exception message = ' + E.Message);
    raise E;
  end;
end;
try
  DoSomething;
except
  on E: Exception do begin
    Log.Debug('Exception message = ' + E.Message);
    raise;
  end;
end;

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy