Discussion:
[omniORB] Questions about self defined exception raising
Luo Yongheng
2008-03-14 18:17:15 UTC
Permalink
Nobody ever talks about exception handling in servants. Here is a question:

If I define my own exception classes, say, derived from standard C++ exceptions, and raise them in my servants, how can I catch them in the main thread? It seems impossible, since we can not control the exception handling in the worker thread that runs into my servants.

Anybody has any idea?


Thierry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20080314/93dd1550/attachment.htm
Martin Trappel
2008-03-17 12:17:13 UTC
Permalink
* Corba User Exceptions are defined in IDL
* There is NO exception inheritance for Corba User Exceptions
* If you throw something that is derived from std::exception from a
servant method you will get a CORBA::UNKNOWN in the client.
Post by Luo Yongheng
If I define my own exception classes, say, derived from standard C++
exceptions, and raise them in my servants, how can I catch them in the
main thread? It seems impossible, since we can not control the exception
handling in the worker thread that runs into my servants.
Anybody has any idea?
Thierry
------------------------------------------------------------------------
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Luo Yongheng
2008-03-17 14:29:53 UTC
Permalink
I understand that, but that is the problem. I don't want to raise exceptions
to clients. I just want to raise some exceptions that are supposed to be
captured by server side, like some logical errors in the servant. These kind
of errors are not supposed to be handled by the clients.

----- Original Message -----
From: "Martin Trappel" <***@gmx.at>
To: <omniORB-***@omniorb-support.com>
Sent: Monday, March 17, 2008 3:16 PM
Subject: Re: [omniORB] Questions about self defined exception raising
Post by Martin Trappel
* Corba User Exceptions are defined in IDL
* There is NO exception inheritance for Corba User Exceptions
* If you throw something that is derived from std::exception from a
servant method you will get a CORBA::UNKNOWN in the client.
Post by Luo Yongheng
If I define my own exception classes, say, derived from standard C++
exceptions, and raise them in my servants, how can I catch them in the
main thread? It seems impossible, since we can not control the exception
handling in the worker thread that runs into my servants.
Anybody has any idea?
Thierry
------------------------------------------------------------------------
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
Martin Trappel
2008-03-17 18:04:15 UTC
Permalink
Post by Luo Yongheng
I understand that, but that is the problem. I don't want to raise
exceptions to clients. I just want to raise some exceptions that are
supposed to be captured by server side, like some logical errors in the
servant. These kind of errors are not supposed to be handled by the
clients.
Oh.
Then you would have to catch these exceptions in the Methods of the
servants - after all, only there you can know how to handle them, right?

When you say "captured by the server side", what is it you wish to do
once the exceptions have been caught? (Logging? Abort Process? Do
nothing?) What would you return to the client upon such an exception?

cheers,
Martin
Luo Yongheng
2008-03-18 14:27:34 UTC
Permalink
Post by Martin Trappel
Post by Luo Yongheng
I understand that, but that is the problem. I don't want to raise
exceptions to clients. I just want to raise some exceptions that are
supposed to be captured by server side, like some logical errors in the
servant. These kind of errors are not supposed to be handled by the
clients.
Oh.
Then you would have to catch these exceptions in the Methods of the
servants - after all, only there you can know how to handle them, right?
When you say "captured by the server side", what is it you wish to do once
the exceptions have been caught? (Logging? Abort Process? Do nothing?)
What would you return to the client upon such an exception?
cheers,
Martin
Main thread that starts the ORB and servants sometimes wants to capture some
exceptions raised by servants code. Theoritically it seems impossible,
because the main thread usually is not the same thread as the servant
thread.

That means, just like you mentioned, on server side we can only capture the
exception in the servant itself. This is sometimes a little inflexible for
writing server applications.

Thanks.
Thierry

Loading...