|
|
|
|||||
|
why client cannot catch user-defined exception in AMI mode?
I define an interface :
interface myI { ["ami"] int myOP(string s) throw myEx ; } but I just find ice_exception(const ::Ice::Exception&) How could I catch "myEx" in callback object? Why not ice_exception(const myEx&)?? my env : c++ , Ice-2.1.0 , linux many thanks ! |
|
|||||
|
ice_throw does not work
Quote:
try{ ex->ice_throw(); } catch(myEx e) { //go to bed } catch(::Ice::Exception e) { //watch TV } I have never gone to bed .... can you give a sample code ? |
|
||||||
|
Hi,
This should work. Try for example to modify the client from the demo/Ice/async demo (available in Ice 3.2.0). Change the implementation of the AMI callback ice_exception method to: Code:
virtual void ice_exception(const Ice::Exception& ex)
{
try
{
ex.ice_throw();
}
catch(const RequestCanceledException&)
{
cerr << "request failed!" << endl;
}
catch(const Ice::Exception& ex)
{
cerr << "sayHello AMI call failed:\n" << ex << endl;
}
}
Also, note that you should catch exceptions by reference not value, so your code should look like the following: Code:
try{
ex.ice_throw();
}
catch(const myEx& e)
{
//go to bed
}
catch(const ::Ice::Exception& e)
{
//watch TV
}
Benoit. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sending Exception To Client from AMI | jesse | Help Center | 1 | 04-25-2007 06:36 PM |
| How to catch ConnectionLostConnection exception in cpp? | Vitaly Berov | Help Center | 5 | 02-27-2007 08:03 AM |
| Problems with user-defined types | davidcr1983 | Help Center | 3 | 07-14-2006 03:12 PM |
| icepack client cannot catch exception | supperstar | Help Center | 6 | 09-08-2005 08:56 AM |
| some problem about user exception | fishinmoon | Help Center | 1 | 09-08-2004 02:37 PM |