Discussion:
[omniORB] Regarding UserException catching Scenario.
Ratheesh .R
2011-07-27 13:13:47 UTC
Permalink
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/6ee53430/attachment.htm
Mayo, Jeff
2011-07-27 21:15:58 UTC
Permalink
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-***@omniorb-support.com
[mailto:omniorb-list-***@omniorb-support.com] On Behalf Of Ratheesh
.R
Sent: Wednesday, July 27, 2011 3:13 AM
To: omniorb-***@omniorb-support.com
Cc: ***@cdactvm.in; ***@cdactvm.in; ***@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
Duncan Grisby
2011-07-28 17:26:06 UTC
Permalink
Post by Mayo, Jeff
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 ,
Why have you implemented a subclass of the InvalidProcess exception?
You are not meant to do that in the C++ language mapping. You are meant
to directly use the InvalidProcess class that omniidl generated. The
problem you are seeing is probably due to that.

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Ratheesh .R
2011-07-28 18:46:32 UTC
Permalink
Hi Duncan,

Yes Duncan you are right
,you Spot it correctly ,that was the real problem. Thanks for your support that
was good enough to resolve the problem.

But in a scenario,
where we want to add some additional methods such as to print the entire
set of array of error messages like stringsequence of error message
then how can we do that ?

For that purpose we tried
with a child class of InvalidProcessImpl inherited from the
InvalidProcess class and
included the additional method in it to print the array of messages and thrown
that instance.

Please suggest me what I
need to do in such kind of scenario ,where I need to add additional method to
display the entire set of array of messages with in one function at exception
class ...?


Thanks
Ratheesh

--- On Thu, 7/28/11, Duncan Grisby <***@grisby.org> wrote:

From: Duncan Grisby <***@grisby.org>
Subject: Re: [omniORB] Regarding UserException catching Scenario.
To: "Ratheesh .R" <***@yahoo.com>
Cc: "omniorb-***@omniorb-support.com" <omniorb-***@omniorb-support.com>, ***@cdactvm.in, ***@cdactvm.in, ***@cdactvm.in
Date: Thursday, July 28, 2011, 4:56 PM
Post by Mayo, Jeff
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 ,
Why have you implemented a subclass of the InvalidProcess exception?
You are not meant to do that in the C++ language mapping. You are meant
to directly use the InvalidProcess class that omniidl generated. The
problem you are seeing is probably due to that.

Duncan.
--
-- Duncan Grisby? ? ? ???--
? -- ***@grisby.org? ???--
???-- http://www.grisby.org --


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20110728/6807d98a/attachment.htm
Brian Neal
2011-07-28 20:28:54 UTC
Permalink
You don't need to add a "method". You can just write a free function. It
would be reusable for other uses as well.
Post by Ratheesh .R
Hi Duncan,
Yes Duncan you are right ,you Spot it correctly ,that was the real
problem. Thanks for your support that was good enough to resolve the
problem.
Post by Ratheesh .R
But in a scenario, where we want to add some additional methods such as to
print the entire set of array of error messages like stringsequence of error
message then how can we do that ?
Post by Ratheesh .R
For that purpose we tried with a child class of InvalidProcessImpl
inherited from the InvalidProcess class and included the additional method
in it to print the array of messages and thrown that instance.
Post by Ratheesh .R
Please suggest me what I need to do in such kind of scenario ,where I need
to add additional method to display the entire set of array of messages with
in one function at exception class ...?
Post by Ratheesh .R
Thanks
Ratheesh
Post by Ratheesh .R
Subject: Re: [omniORB] Regarding UserException catching Scenario.
Date: Thursday, July 28, 2011, 4:56 PM
Post by Mayo, Jeff
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 ,
Why have you implemented a subclass of the InvalidProcess exception?
You are not meant to do that in the C++ language mapping. You are meant
to directly use the InvalidProcess class that omniidl generated. The
problem you are seeing is probably due to that.
Duncan.
--
-- Duncan Grisby --
-- http://www.grisby.org --
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20110728/c3eff6cf/attachment.htm
Duncan Grisby
2011-07-28 20:39:46 UTC
Permalink
On Thu, 2011-07-28 at 09:28 -0500, Brian Neal wrote:

[...]
Post by Brian Neal
Post by Ratheesh .R
But in a scenario, where we want to add some additional methods such
as to print the entire set of array of error messages like
stringsequence of error message then how can we do that ?
You don't need to add a "method". You can just write a free function.
It would be reusable for other uses as well.
Indeed. A free function also has the advantage that it will work on the
client side when it catches an exception. Messing around with the class
thrown by the server won't change the fact that the client gets the
exception generated by the IDL compiler.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Ratheesh .R
2011-07-29 17:34:09 UTC
Permalink
Hello Duncan,



Thanks Duncan , with your valuable
information I have been able to complete successfully the exception
evaluation with omniORB .With this exercise I could convey about the
powerfulness of the omniORB product and your excellent support to our
higher project management .






Thanks
Ratheesh














--- On Thu, 7/28/11, Duncan Grisby <***@grisby.org> wrote:

From: Duncan Grisby <***@grisby.org>
Subject: Re: [omniORB] Regarding UserException catching Scenario.
To: "Brian Neal" <***@gmail.com>
Cc: "Ratheesh .R" <***@yahoo.com>, "omniorb-***@omniorb-support.com" <omniorb-***@omniorb-support.com>, ***@cdactvm.in, ***@cdactvm.in, ***@cdactvm.in
Date: Thursday, July 28, 2011, 8:09 PM

On Thu, 2011-07-28 at 09:28 -0500, Brian Neal wrote:

[...]
Post by Ratheesh .R
But in a scenario, where we want to add some additional methods such
as to print the entire set of array of error messages like
stringsequence of error message then how can we do that ?
You don't need to add a "method".? You can just write a free function.
It would be reusable for other uses as well.
Indeed. A free function also has the advantage that it will work on the
client side when it catches an exception. Messing around with the class
thrown by the server won't change the fact that the client gets the
exception generated by the IDL compiler.

Cheers,

Duncan.
--
-- Duncan Grisby? ? ? ???--
? -- ***@grisby.org? ???--
???-- http://www.grisby.org --


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20110729/cbcab902/attachment.htm
Ratheesh .R
2011-07-29 17:36:27 UTC
Permalink
Thanks Brain ,your point is correct and i got the result.

thanks
Ratheesh

--- On Thu, 7/28/11, Brian Neal <***@gmail.com> wrote:

From: Brian Neal <***@gmail.com>
Subject: Re: [omniORB] Regarding UserException catching Scenario.
To: "Ratheesh .R" <***@yahoo.com>
Cc: "omniorb-***@omniorb-support.com" <omniorb-***@omniorb-support.com>, ***@cdactvm.in, ***@cdactvm.in, "Duncan Grisby" <***@grisby.org>, ***@cdactvm.in
Date: Thursday, July 28, 2011, 7:58 PM

You don't need to add a "method".? You can just write a free function.? It would be reusable for other uses as well.
Post by Ratheesh .R
Hi Duncan,
Yes Duncan you are right ,you Spot it correctly ,that was the real problem. Thanks for your support that was good enough to resolve the problem.
But in a scenario, where we want to add some additional methods such as to print the entire set of array of error messages like stringsequence of error message then how can we do that ?
For that purpose we tried with a child class of InvalidProcessImpl inherited from the InvalidProcess class and included the additional method in it to print the array of messages and thrown that instance.
Please suggest me what I need to do in such kind of scenario ,where I need to add additional method to display the entire set of array of messages with in one function at exception class ...?
Thanks
Ratheesh
Post by Ratheesh .R
Subject: Re: [omniORB] Regarding UserException catching Scenario.
Date: Thursday, July 28, 2011, 4:56 PM
Post by Mayo, Jeff
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 ,
Why have you implemented a subclass of the InvalidProcess exception?
You are not meant to do that in the C++ language mapping. You are meant
to directly use the InvalidProcess class that omniidl generated. The
problem you are seeing is probably due to that.
Duncan.
--
-- Duncan Grisby? ? ? ???--
???-- http://www.grisby.org --
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20110729/321c977c/attachment.htm
Loading...