Archived
This forum has been archived. Please start a new discussion on GitHub.
how to catch ICE exception in Qt program?
rolandsun
beijing
in Help Center
Ice 3.4.1
Compiler gcc 4.1.2
OS Centos 5.3
I try to catch exception raised in a Qt and Ice program ,but it crashed and
report :
Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.
terminate called after throwing an instance of 'IceUtil::NullHandleException'
what(): /usr/include/IceUtil/Handle.h:46: IceUtil::NullHandleException
Program received signal SIGABRT, Aborted.
Compiler gcc 4.1.2
OS Centos 5.3
I try to catch exception raised in a Qt and Ice program ,but it crashed and
report :
Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.
terminate called after throwing an instance of 'IceUtil::NullHandleException'
what(): /usr/include/IceUtil/Handle.h:46: IceUtil::NullHandleException
Program received signal SIGABRT, Aborted.
0
Comments
-
How do you try to catch the exceptions?
I'm not very familiar with Qt but it sounds like you should ensure that your event handlers don't let Ice exceptions go through. You can easily catch Ice exceptions by wrapping your code in a try/catch block:try { ... } catch(const Ice::Exception&) { // Handle the exception here. }
Or you could also instead catch std::exception since Ice::Exception inherits from std::exception.
Cheers,
Benoit.0 -
thanks ,BenoitOr you could also instead catch std::exception since Ice::Exception inherits from std::exception.
I tried std::exception,it do not work too
My codes are as followingSliProdBasePtr prod; SliProdReqMsg *reqmsg=(SliProdReqMsg*)msg; try { schdPrx->GetProduct(*reqmsg,prod); } catch (const IceUtil::NullHandleException&) { //process execption } catch(const Ice::Exception &e){ cerr<<e<<endl; }
roland0 -
Something seems to be seriously broken if exception handling doesn't work. Or is the IceUtil::NullHandleException exception perhaps occurring somewhere else?
I recommend setting the Ice.NullHandleAbort property to 1 when initializing the communicator. Instead of throwing an exception, your program will abort at the point where the null handle is used. You can use gdb to get the stack trace of the abort.
Cheers,
Benoit.0