[omniORB] Regarding UserException catching Scenario.

Mayo, Jeff jeff.mayo at transcore.com
Wed Jul 27 12:15:13 BST 2011


Your throw statement in the server code is the problem.  The C++ mapping
requires that the server treat exceptions like out parameters, so you
should change the throw statement to the following:

 

throw ( InvalidProcessImpl( 2, CORBA::string_dup("Error in Terminating
the process ")));

 

As usual, see Advanced CORBA Programming with C++ by Henning & Vinoski
for more complete information.

 

From: omniorb-list-bounces at omniorb-support.com
[mailto:omniorb-list-bounces at omniorb-support.com] On Behalf Of Ratheesh
.R
Sent: Wednesday, July 27, 2011 3:13 AM
To: omniorb-list at omniorb-support.com
Cc: deepapp at cdactvm.in; ratheeshr at cdactvm.in; susanj at cdactvm.in
Subject: [omniORB] Regarding UserException catching Scenario.

 

Hello OmniORB experts,

 

First of all thanks for your wonderful OmniORB product and supports that
you are providing.

 

Let me ask you one question regarding UserException, as a part of our
upcoming project we are evaluating omniORB and we are struggling to
evaluate the UserException scenario.

 

please see the below details and suggest me your solution ,

 

1) In IDL we have provided the User exceptions with in the raises
function as like below,

void terminate() raises ( ExecutableDevice::InvalidProcess )

 

with InvalidProcess having members of,

 

short ErrorNumber;

string ErrorMsg;

 

2)At the server side we have implemented ExecutableDeviceImpl and
InvalidProcessImpl objects

and with in the ExecutableDeviceImpl object we have created the function
terminate () and throwing the UserException as like below ,

 

void terminate() throw ( ExecutableDevice::InvalidProcess )

{

throw ( InvalidProcessImpl( 2, "Error in Terminating the process "));

}

 

Note :- this InvalidProcessImpl is inherited from InvalidProcess and
std::runtime_error exception.

 

3) At the client side when we are calling the terminate process then
getting the UserException correctly ,but we are not able to see the
error message that raised at server side ie, ErrorNumber and ErrorMsg.
Please see the code I have written client side.

 

//after ORB initialization and NameResolving of ExecutableDevice we are
calling the terminate function,

try

{

ExecutableDevice_mgr->terminate();

}

catch( CORBA::UserException& ex)

{

cerr<<"\n CORBA user Exception ";

cerr<<ex._rep_id();

cerr<<ex._name();

 

//CF::ExecutableDevice::InvalidProcess*
//inval=CF::ExecutableDevice::InvalidProcess::_downcast(&ex);

//cerr<<"\n THE DATA="<<inval->ErrorMsg;

 

//CF::ExecutableDevice::InvalidProcess
//exeDev=CF::ExecutableDevice::InvalidProcess::_narrow(ex);

//cerr<<exeDev.ErrorMsg;

 

}

 

i am getting the output at client side like below,which is correct but
not able to print the ErrorMsg and ErrorNumber of InvalidProcess .

 

Output at client :- CORBA UserException:-
IDL:CF/ExecutableDevice/InvalidProcess:1.0InvalidProcess

 

i have tried with down cast and narrow methods to print the
InvalidProcess Exception details, which you can see in my code above but
was not successful,

 

do u find any mistake in my approach ?? or do i have to do any
additional methods to get the UserException data at client side.?

 

awaiting for your valuable information,

 

thanks

Ratheesh

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20110727/f23572f6/attachment.htm


More information about the omniORB-list mailing list