Skip to content

Commit

Permalink
report more detailed errormessages, on why loading a project or proje…
Browse files Browse the repository at this point in the history
…ctgroup failed
  • Loading branch information
Memnarch committed Aug 30, 2015
1 parent f634280 commit 2b3bc0a
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
2 changes: 2 additions & 0 deletions DN.Installer.pas
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ function TDNInstaller.ProcessProjects(const AProjects: TArray<TProject>; const A
else
begin
DoMessage(mtError, 'Failed to load Groupproject ' + LProjectfile);
DoMessage(mtError, LGroupInfo.LoadingError);
end;
end
else if SameText(LFileExt, CProject) then
Expand All @@ -446,6 +447,7 @@ function TDNInstaller.ProcessProjects(const AProjects: TArray<TProject>; const A
else
begin
DoMessage(mtError, 'Failed to load project ' + LProjectFile);
DoMessage(mtError, LInfo.LoadingError);
end;
end
else
Expand Down
2 changes: 2 additions & 0 deletions DN.ProjectGroupInfo.Intf.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ interface
function GetFileName: string;
function GetProjects: TList<IDNProjectInfo>;
function LoadFromFile(const AFileName: string): Boolean;
function GetLoadingError: string;
property FileName: string read GetFileName;
property Projects: TList<IDNProjectInfo> read GetProjects;
property LoadingError: string read GetLoadingError;
end;

implementation
Expand Down
34 changes: 32 additions & 2 deletions DN.ProjectGroupInfo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ interface
TDNProjectGroupInfo = class(TInterfacedObject, IDNProjectGroupInfo)
private
FFileName: string;
FLoadingError: string;
FProjects: TList<IDNProjectInfo>;
function GetFileName: string;
function GetProjects: TList<IDNProjectInfo>;
function GetLoadingError: string;
procedure SetError(const AError: string);
public
constructor Create();
destructor Destroy(); override;
function LoadFromFile(const AFileName: string): Boolean;
property FileName: string read GetFileName;
property Projects: TList<IDNProjectInfo> read GetProjects;
property LoadingError: string read GetLoadingError;
end;

implementation
Expand Down Expand Up @@ -59,6 +63,11 @@ function TDNProjectGroupInfo.GetFileName: string;
Result := FFileName;
end;

function TDNProjectGroupInfo.GetLoadingError: string;
begin
Result := FLoadingError;
end;

function TDNProjectGroupInfo.GetProjects: TList<IDNProjectInfo>;
begin
Result := FProjects;
Expand All @@ -69,7 +78,7 @@ function TDNProjectGroupInfo.LoadFromFile(const AFileName: string): Boolean;
LXML: IXMLDocument;
LItemGroup, LProjects, LProjectRoot: IXMLNode;
LProject: IDNProjectInfo;
LBasePath: string;
LBasePath, LProjectFile: string;
begin
Result := False;
if TFile.Exists(AFileName) then
Expand All @@ -88,16 +97,37 @@ function TDNProjectGroupInfo.LoadFromFile(const AFileName: string): Boolean;
while Assigned(LProjects) do
begin
LProject := TDNProjectInfo.Create();
if not LProject.LoadFromFile(TPath.Combine(LBasePath, LProjects.Attributes['Include'])) then
LProjectFile := TPath.Combine(LBasePath, LProjects.Attributes['Include']);
if not LProject.LoadFromFile(LProjectFile) then
begin
SetError('Could not load Project ' + LProjectFile + ' Reason: ' + LProject.LoadingError);
Exit;
end;

FProjects.Add(LProject);
LProjects := LProjects.NextSibling;
end;
Result := True;
end
else
begin
SetError('ItemGroup-Node not found');
end;
end
else
begin
SetError('Project-Node not found');
end;
end
else
begin
SetError('File does not exist');
end;
end;

procedure TDNProjectGroupInfo.SetError(const AError: string);
begin
FLoadingError := AError;
end;

end.
2 changes: 2 additions & 0 deletions DN.ProjectInfo.Intf.pas
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ interface
function GetFileName: string;
function GetSupportedPlatforms: TDNCompilerPlatforms;
function LoadFromFile(const AProjectFile: string): Boolean;
function GetLoadingError: string;
property IsPackage: Boolean read GetIsPackage;
property IsRuntimeOnlyPackage: Boolean read GetIsRuntimeOnlyPackage;
property BinaryName: string read GetBinaryName;
property DCPName: string read GetDCPName;
property FileName: string read GetFileName;
property SupportedPlatforms: TDNCompilerPlatforms read GetSupportedPlatforms;
property LoadingError: string read GetLoadingError;
end;

implementation
Expand Down
26 changes: 26 additions & 0 deletions DN.ProjectInfo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TDNProjectInfo = class(TInterfacedObject, IDNProjectInfo)
FIsPackage: Boolean;
FIsRuntimeOnlyPackage: Boolean;
FSupportedPlatforms: TDNCompilerPlatforms;
FLoadingError: string;
function GetBinaryName: string;
function GetDCPName: string;
function GetIsPackage: Boolean;
Expand All @@ -34,6 +35,8 @@ TDNProjectInfo = class(TInterfacedObject, IDNProjectInfo)
function GetIsRuntimeOnlyPackage: Boolean;
function GetFileName: string;
function GetSupportedPlatforms: TDNCompilerPlatforms;
function GetLoadingError: string;
procedure SetError(const AError: string);
public
function LoadFromFile(const AProjectFile: string): Boolean;
property IsPackage: Boolean read GetIsPackage;
Expand All @@ -42,6 +45,7 @@ TDNProjectInfo = class(TInterfacedObject, IDNProjectInfo)
property DCPName: string read GetDCPName;
property FileName: string read GetFileName;
property SupportedPlatforms: TDNCompilerPlatforms read GetSupportedPlatforms;
property LoadingError: string read GetLoadingError;
end;

implementation
Expand Down Expand Up @@ -98,6 +102,11 @@ function TDNProjectInfo.GetIsRuntimeOnlyPackage: Boolean;
Result := FIsRuntimeOnlyPackage;
end;

function TDNProjectInfo.GetLoadingError: string;
begin
Result := FLoadingError;
end;

function TDNProjectInfo.GetPropertyGroupOfConfig(const AProject: IXMLNode;
const AConfig: string): IXMLNode;
var
Expand Down Expand Up @@ -208,9 +217,26 @@ function TDNProjectInfo.LoadFromFile(const AProjectFile: string): Boolean;
if FSupportedPlatforms = [] then
FSupportedPlatforms := [cpWin32];
Result := True;
end
else
begin
SetError('PropertyGroup-Node not found');
end;
end
else
begin
SetError('Project-Node not found');
end;
end
else
begin
SetError('File not found');
end;
end;

procedure TDNProjectInfo.SetError(const AError: string);
begin
FLoadingError := AError;
end;

end.

0 comments on commit 2b3bc0a

Please sign in to comment.