TProcess and EProcess

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

TProcess and EProcess

adrian_m
Hello,

I am trying to catch the possible exceptions that may ocur
when executing processes with TProcess (such as cases when
the program doesn't exist or is not in the path).

   try
      p := TProcess.Create(nil);
      p.CommandLine := 'psql';
      p.Options := p.Options + [poStderrToOutPut,poNewConsole,poWaitOnExit];
      p.Execute;

   except
      on EProcess do ShowMessage('EProcess !');
      else
         ShowMessage('Mysterious exception, other than EProcess ...' );
   end;

The compiler tells me that it doesn't recognize EProcess.
What am I doing wrong?


Thanks,
Adrian Maier
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: TProcess and EProcess

Michael Van Canneyt


On Wed, 15 Mar 2006, Adrian Maier wrote:

> Hello,
>
> I am trying to catch the possible exceptions that may ocur
> when executing processes with TProcess (such as cases when
> the program doesn't exist or is not in the path).
>
>   try
>      p := TProcess.Create(nil);
>      p.CommandLine := 'psql';
>      p.Options := p.Options + [poStderrToOutPut,poNewConsole,poWaitOnExit];
>      p.Execute;
>
>   except
>      on EProcess do ShowMessage('EProcess !');
>      else
>         ShowMessage('Mysterious exception, other than EProcess ...' );
>   end;
>
> The compiler tells me that it doesn't recognize EProcess.
> What am I doing wrong?

it should be:

      on E : EProcess do ShowMessage('EProcess !');

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal