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

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

There is a newer version: 1.12.1
Show newest version

Why is this an issue?

When an assertion without a message fails, it raises a generic EAssertionFailed exception, which is of little use when debugging. Providing a message ensures that the assertion is more immediately identifiable and helpful when it fails.

How to fix it

Add a descriptive message string as the second parameter to the System.Assert call:

procedure Foo(Bar: TObject);
begin
  Assert(Assigned(Bar));
end;
procedure Foo(Bar: TObject);
begin
  Assert(Assigned(Bar), 'Bar must be initialized');
end;

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy