Delphi Try except block dodging its purpose

80 Views Asked by At

I made a func to check if a TObjectList is empty because the .OwnsObjects didnt work and just using [0] raised a error so i made this

function IsEmptyList(List:TObjectList<TImage>):Boolean;
begin
  try
    List[0];
    result:=False;
  except
    result:=True;
  end;
end;

I put the List[0] in thy try block and in theory it should raise the empty exception as normal and run the except block but instead it raises the exception and crashes the app. enter image description here

enter image description here

I expected the code to run the except block but it crashed

0

There are 0 best solutions below