uses System.SysUtils,
System.Generics.Collections;
type
EIsNilException = class(Exception);
EIsEmptyException = class(Exception);
procedure ThrowWhenNilOrEmpty(
List: TList<Integer>);
begin
if List = nil then
raise EIsNilException.Create('is nil');
if List.Count = 0 then
raise EIsEmptyException.Create('is empty');
end;
begin
try
ThrowWhenNilOrEmpty(nil);
except
//Exception catches all descendants
on E: Exception do
WriteLn('Error happened ', E.ClassName);
end;
end.