MG: added some more error messages for TProcess

git-svn-id: trunk@445 -
This commit is contained in:
lazarus 2001-11-21 12:51:00 +00:00
parent 2867614d29
commit b6104ccf59
3 changed files with 78 additions and 5 deletions

View File

@ -70,9 +70,15 @@ function ErrorTypeNameToType(const Name:string): TErrorType;
implementation
// to get more detailed error messages consider the os
{$IFDEF linux}
uses linux;
{$ENDIF linux}
{$IFDEF Linux}
uses
{$IFDEF Ver1_0}
Linux
{$ELSE}
Unix
{$ENDIF}
;
{$ENDIF}
function ErrorTypeNameToType(const Name:string): TErrorType;
@ -178,7 +184,8 @@ begin
// TProcess does not report, if a program can not be executed
// to get good error messages consider the OS
{$IFDEF linux}
if not Linux.Access(CmdLine,Linux.X_OK) then begin
if not Access(CmdLine,{$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.X_OK) then
begin
case LinuxError of
sys_eacces: OutputLine:='execute access denied for "'+CmdLine+'"';
sys_enoent: OutputLine:='a directory component in "'+CmdLine+'"'
@ -336,6 +343,9 @@ end.
{
$Log$
Revision 1.21 2001/11/21 12:51:00 lazarus
MG: added some more error messages for TProcess
Revision 1.20 2001/11/09 20:48:36 lazarus
Minor fixes
Shane

View File

@ -106,6 +106,17 @@ function ShowExtToolDialog(ExtToolList: TExternalToolList;
implementation
// to get more detailed error messages consider the os
{$IFDEF Linux}
uses
{$IFDEF Ver1_0}
Linux
{$ELSE}
Unix
{$ENDIF}
;
{$ENDIF}
function ShowExtToolDialog(ExtToolList: TExternalToolList;
TransferMacros: TTransferMacroList):TModalResult;
@ -221,7 +232,7 @@ end;
function TExternalToolList.Run(Index: integer;
Macros: TTransferMacroList): TModalResult;
var WorkingDir, Filename, Params: string;
var WorkingDir, Filename, Params, AText: string;
TheProcess: TProcess;
begin
Result:=mrCancel;
@ -233,6 +244,28 @@ begin
and Macros.SubstituteStr(WorkingDir)
and Macros.SubstituteStr(Params) then begin
writeln('[TExternalToolList.Run] ',Filename,' ',Params);
// TProcess does not report, if a program can not be executed
// to get good error messages consider the OS
{$IFDEF linux}
if not {$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.Access(Filename,
{$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.X_OK) then
begin
case LinuxError of
sys_eacces: AText:='execute access denied for "'+Filename+'"';
sys_enoent: AText:='a directory component in "'+Filename+'"'
+' does not exist or is a dangling symlink';
sys_enotdir: AText:='a directory component in "'+Filename+'"'
+' is not a directory';
sys_enomem: AText:='insufficient memory';
sys_eloop: AText:='"'+Filename+'" has a circular symbolic link';
else
AText:='unable to execute "'+Filename+'"';
end;
MessageDlg('Error executing tool',
AText, mtError, [mbOk], 0);
exit;
end;
{$ENDIF linux}
try
TheProcess:=TProcess.Create(Filename+' '+Params,[poRunSuspended,
poUsePipes, poNoConsole]);

View File

@ -380,6 +380,13 @@ var
implementation
uses
{$IFDEF Linux}
{$IFDEF Ver1_0}
Linux,
{$ELSE}
Unix,
{$ENDIF}
{$ENDIF}
ViewUnit_dlg, Math, LResources, Designer;
@ -3562,6 +3569,26 @@ writeln('[TMainIDE.DoRunProject] A');
begin
try
writeln(' EXECUTING "',ProgramFilename,'"');
// TProcess does not report, if a program can not be executed
// to get good error messages consider the OS
{$IFDEF linux}
if not {$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.Access(ProgramFilename,
{$IFDEF Ver1_0}Linux{$ELSE}Unix{$ENDIF}.X_OK) then
begin
case LinuxError of
sys_eacces: AText:='execute access denied for "'+ProgramFilename+'"';
sys_enoent: AText:='a directory component in "'+ProgramFilename+'"'
+' does not exist or is a dangling symlink';
sys_enotdir: AText:='a directory component in "'+ProgramFilename+'"'
+' is not a directory';
sys_enomem: AText:='insufficient memory';
sys_eloop: AText:='"'+ProgramFilename+'" has a circular symbolic link';
else
AText:='unable to execute "'+ProgramFilename+'"';
end;
raise Exception.Create(AText);
end;
{$ENDIF linux}
TheProcess:=TProcess.Create(ProgramFilename,
[poRunSuspended,poUsePipes,poNoConsole]);
@ -4756,6 +4783,9 @@ end.
{ =============================================================================
$Log$
Revision 1.154 2001/11/21 12:51:00 lazarus
MG: added some more error messages for TProcess
Revision 1.153 2001/11/20 19:39:45 lazarus
MG: DoRunProject writes the programfilename