How about raising an exception yourself if the function returns false?

[pascal]try
...
if open = FALSE then raise Exception.Create('open failed');

...

except
FreeMem(p);
Object.Free;
OtherObject.Free;
CloseSomething();
end;[/pascal]