TJPEGImage.LoadFromFile

If the LoadFromFile fail to open a JPEG file, the program will halt and raise a exception !
As a result, how can I control this without halt the program ?

Andrew
andrewyuAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
MadshiConnect With a Mentor Commented:
Hi Andrew,

use this one:

  try
    jpeg.LoadFromFile(...);
    result:=true;
  except result:=false end;

Regards, Madshi.
0
 
andrewyuAuthor Commented:
Thank you very much !

But, what is the exception it raise ?

Andrew
0
 
MadshiCommented:
Heh? What do you mean?

Do you want to have the exception text? Then do something like this:

  try
    ...
    result:='Everything is fine...';
  except
    if ExceptObject is Exception then
         result:=(ExceptObject as Exception).Message
    else result:='Unknown Exception...';
  end;

Regards, Madshi.
0
 
andrewyuAuthor Commented:
Yes, it exact what I meant !

Thank you very much for your help !

Andrew
0
 
MadshiCommented:
No problem...  :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.