Sign in to follow this  
CProgrammer

catching unhandled exceptions

Recommended Posts

Hi, I have a php script that executes a C++ application. Now in the unlikely event that the C++ app terminates with an unhandled exception how can I ensure that the php script catches this and continues working with appropriate measures. On Windows and apache I get an unhandled exception box which I close, much rather I would want this not to happen, instead have the php script deal wth it. I know a C++ app shouldnt have any exceptions of this kind but since you never knw I dont want this crashing the server or giing a user awkward responses. -CProgrammer

Share this post


Link to post
Share on other sites
You can have a try catch statement in your main function that covers everything the program does. Although "continues working with appropriate measures" will be difficult and specific to each cause of the exception.

Share this post


Link to post
Share on other sites
If the C++ program crashes, it will appear to your PHP script as though the program finished running. You don't need to do anything special to catch exceptions.

However, the crashed program still crashed, and so its a good bet that it didn't finish up whatever it was supposed to be doing. It is up to you to decide if that output is reliable, and if you could continue working.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this