freelanceprogrammers.org Forum Index » Delphi

hox to prevent delphi showing dialog error


View user's profile Post To page top
jobbyworld2 Posted: Mon Oct 23, 2006 5:43 am


Joined: 23 Oct 2006

Posts: 5
hox to prevent delphi showing dialog error
Please,

What is the best way to never see error dialog ?

when in python illegal operation like importing module doesn`t exist
an error dialog showing


In my pythonEngine Component i do fatalmsgdls=False.
My code to exec my python file

try

gEngine.ExecStrings(templist);

except

showmessage(`python erreur`); -> this never occurs

end;



When error occurs in python, I`ve always the error dialog showing,

I want to redirect all errors to console without dialog.

If Someone have an Idea.
Reply with quote
Send private message
View user's profile Post To page top
morgan_martinet Posted: Tue Oct 24, 2006 7:02 am


Joined: 29 Apr 2005

Posts: 103
hox to prevent delphi showing dialog error
Hi,

FatalMsgDlgs is only used when P4D can`t find/initialize Python.dll
and this has nothing to do with executing scripts that raise an
error.

Your "try…except" code is perfectly valid and should catch the
exception.

If it doesn`t, it means that Python did not raise an exception!

And in fact, you should do:

Try
PythonEngine1.ExecString("print MyVarThatDoesNotExist");
Except
On E: EPythonError do
ShowMessage(`Python Error: ` + E.Message);
End;


You can also catch syntax errors like that:

Try
PythonEngine1.ExecString("print dir(");
Except
On E: EPySyntaxError do
ShowMessage(`Syntax Error: ` + E.Message);
End;

Also, if you`re writing a Console application, then you should set
RedirectIO to False. Note that Python will print the error before we
raise the Delphi exception.

Bye,

Morgan

--- In pythonfordelphi@yahoogroups.com, "jobbyworld2"
<jobbyworld@...> wrote:
>
>
> Please,
>
> What is the best way to never see error dialog ?
>
> when in python illegal operation like importing module doesn`t
exist
> an error dialog showing
>
>
> In my pythonEngine Component i do fatalmsgdls=False.
> My code to exec my python file
>
> try
>
> gEngine.ExecStrings(templist);
>
> except
>
> showmessage(`python erreur`); -> this never occurs
>
> end;
>
>
>
> When error occurs in python, I`ve always the error dialog showing,
>
> I want to redirect all errors to console without dialog.
>
> If Someone have an Idea.
>
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help