Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-25-2005, 04:06 AM   #1
Registered: Nov 2003
Posts: 55

Rep: Reputation: 15
Exception Handling C++


I'm using C++ in Windows...

I'm running a file from my application,
this files sometimes gives a Error (The "Send Error Report to Microsoft" kind of error....)

I'm trying to catch that exception from the application, but since it's in a different file, it's not being caught..

This is what I'm doing..

		cout << "Exception";
Is it possible to catch the exception of file.exe from my application?!

Any suggestions?!

Thanks a lot in advance,

Old 07-25-2005, 10:37 AM   #2
Registered: Sep 2004
Location: /dev/urandom
Distribution: Gentoo
Posts: 171

Rep: Reputation: 30
Correct me if I'm wrong everyone, but putting a try around a system() call like that will catch any errors generated by system() but not the program it runs. And I seriously doubt system will even throw an exception since it is a C function and not a C++ function.

I could be off base though. And it sounds like your doing M$ dev and this is a Linux forum.
Old 07-26-2005, 01:45 PM   #3
Registered: May 2004
Location: England
Distribution: SuSE linux 10.0 OSS
Posts: 78

Rep: Reputation: 15
He may be a programmer on the "Dark Side", but this is a non *NIX forum for general programming remember.

If this file is crashing, shouldn't Windows be seeing this and asking you to submit a bug report? you can see the error output from what Windows has caught can't you?
It has flashed up when I've ported my applications to windows.
Old 07-26-2005, 11:07 PM   #4
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
C++ exceptions are a C++ language construct valid only within the C++ portions of a C++ program. You can't pass it between separate processes.

Having said that, MS Windows has an OS-level capability called "SEH" ("Structured Exception Handling"). And, I believe, you *can* use it between processes. To confuse things further, Microsoft uses the OS-specific feature of "SEH" to implement their language-specific construct of C++ exceptions. But the fact remains: no, you cannot catch problems in a child .exe by wrapping your "system()" call in a C++ exception. Nope.

The easiest way to debug what might be going wrong with "file.exe" is to debug file.exe separately.

The most robust way to spawn a child process and then detect any problem that might have occurred is to use "fork/exit/wait" (or similar APIs) on *nix, or "Createprocess()" on Windows.

'Hope that helps .. PSM


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception Handling vipinsharma Programming 2 09-25-2005 11:05 AM
help createing exception class from base STL exception qwijibow Programming 4 04-20-2005 05:23 AM
Exception handling compilation errors ashwinipahuja Programming 6 07-03-2004 06:46 AM
python; exception handling TheLinuxDuck Programming 2 08-20-2003 02:01 PM
Runtime Exception vs. Exception mikeshn Programming 1 09-22-2002 05:33 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration