Link to home
Start Free TrialLog in
Avatar of Chrysaor
Chrysaor

asked on

How to handle errors in C++

I have a timer which loads a picture using ThePIctureName->LoadFromFile every x seconds. The only problem is , that the file i am trying to load is dynamically changing by another application( can be deleted in 1s, and be reconstructed the next sec) Therefore,at certain moments, my application presents error message that it cannot load the picture.

What I want is to create an event like this: WhenErrorOccures --> To ignore that error, and try to load the file again. How do i do this? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of George Tokas
George Tokas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kent Olsen

I'd go with George's second suggestion (try/catch).  If the host file is changing quite often, just checking for the file may not be robust enough as the file can be deleted (or created) or its size change between checking for the file and actually trying to read it.


Good Luck,
Kent
Avatar of Chrysaor
Chrysaor

ASKER

The try/catch didn't work.. An error did pop up again..
I don't have a habbit to stop monitoring ANY Q I participate...
I'm and will be here Chrysaor...
What kind of error you have??

George Tokas.
>> The try/catch didn't work.. An error did pop up again..

Check your project settings.  It may be that this error is being handled by the default handlers.


Kent