Frank Schönheit - Sun Microsystems Germany wrote:
Hi,
having to implement a service which has an explicit constructor taking
two arguments, which are necessary for operation of the component, I
wonder whether we already have some kind of NotInitializedException.
That is, technically it is possible to create the component without
actually invoking its constructor, so that is something I have to care
for in the implementation. I would like to do so by throwing a dedicated
exception, which clearly states the problem, whenever some (non-trivial)
method is invoked before fully constructing the object.
I imagine something like the following:
/** is thrown when a component is attempted to be used before it was
completely constructed.
*/
exception NotInitializedException : public Exception
{
};
As you already replied, I too think it should be a RuntimeException.
- Do we already have something like this (perhaps not with this name,
but with this semantics)?
- Does it make sense to put this into css.lang? I'd say so, since
- this is where XInitialization resides
- we're talking about a basic "UNO language" feature here, namely
constructors
- Should this go into udkapi or offapi? I'd say the former (again for
consistency with XInitialization)
css.lang and ukdapi.
- Strictly speaking, the thingie should be named
NotConstructedException: The fact that service constructors are
implemented using XInitialization is a mere abus^W implementation
detail (which hopefully will change sooner or later). So, it might
make sense to not refer to "init" in the exception name.
I would argue that it should be named NotInitializedException: Properly
using a service constructor can never cause this exception. It is using
the to-be-deprecated back door of createInstance/initialize that can
cause it.
Then again, not sure if a dedicated NotInitializedException is really
useful, or if a plain RuntimeException (with an appropriate message
string) would suffice. What code would catch and handle
NotInitializedException (indicating a programming error)?
-Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]