![]() | Steema Issues DatabaseNote: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;otherwise you can use StackOverflow. Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy. |
| Summary: | Return value for LoadFromFile | ||
|---|---|---|---|
| Product: | VCL TeeChart | Reporter: | yeray alonso <yeray> |
| Component: | Export | Assignee: | Steema Issue Manager <issuemanager> |
| Status: | RESOLVED WONTFIX | ||
| Severity: | enhancement | CC: | david |
| Priority: | Low | ||
| Version: | 140512 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows | ||
| URL: | http://www.teechart.net/support/viewtopic.php?f=1&t=15167 | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
| Bug Depends on: | |||
| Bug Blocks: | 912 | ||
|
Description
yeray alonso
2014-09-08 08:08:04 EDT
Returning a Boolean will not indicate the exact cause.
Correct behaviour is to raise an exception, being the exception class and properties the info about the problem.
See for example Classes.pas TStrings LoadFromFile:
procedure TStrings.LoadFromFile(const FileName: string);
var
Stream: TStream;
begin
Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
try
LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
OurTTeeSeriesSourceFile.LoadFromFile, TImportChart.LoadFromFile and TeeStore.pas unit LoadChartFromFile, all use the RTL default TFileStream classes.
A custom function can always "eat" the exception and return a boolean, if desired:
uses
TeeStore;
function Load(const AChart:TCustomChart; const AFile:String):Boolean;
begin
try
LoadChartFromFile(AChart,AFile);
result:=True;
except
on Exception do
begin
// EAT
result:=False;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
if Load(Chart1,'test.tee') then
Caption:='OK'
else
Caption:='BAD';
end;
However, this is not recommended. Exceptions must surface-up to callers.
|