Mike Traum wrote: > Dealing with the error is my issue. > > XMultiComponentFactory.createInstanceWithContext throws only one > exception type, com.sun.star.uno.Exception. How can I tell what error > caused the Exception? If it is because of the version problem, I'd > like to report that to the user. If it is some other connectivity > problem, report that.
I'm not sure if this is true. The declaration says that it can throw css.uno.Exception. But this should be seen as a declaration that it can throw *any* exception (because css.uno.Exception is the base class of them). This is reasonable for such a generic method, the failure of a service installation can have a lot of reasons. I don't know the details, but I would expect that in case the service is not available (because it is not installed) you should get an exception that expresses this fact, not just a "general" one. If this doesn't happen it could be seen as a bug (IMHO). But I wouldn't expect to get an exeption that is telling something about a "version problem", because the availability of a UNO service is not related to any "version" of an *application*. This should be clear because UNO is an application independent concept. It's a runtime system that is *used* by applications. You might be able to have means to ask for the version of a particular application (f.e. an explicit API for this or a query for a configuration setting), but this is nothing that UNO itself can know, and service instantiation using the component context or its service factory is something that usually is completely done by the UNO runtime without any application code involved. But there are even practical reasons why the concepts of service availability and application version are two concepts that don't match. As an example, services are very often provided as single libraries that can be installed independently from the rest. So it is possible to deploy UNO components into a particular installation of OOo that this installation (or more concrete: its version) usually doesn't provide. If you took the version number as indication for the available services and then stopped your program if the version doesn't match you would abort your program for no real reason. There is only one reasonable way to find out if a service is available: ask for it. If you don't get it, it isn't there. The reason may be that it isn't installed at all, something in the registration is wrong, some necessary libraries are missing or many other things. If the reason is the first one: all that UNO can tell you is that it isn't there. If this happens because you have "the wrong application version" or because its installation is corrupted or something else is out of the scope of UNO. > Is this actually an instance of subclass of Exception? If so, what > are the possibilities for > XMultiComponentFactory.createInstanceWithContext? > > Or, will this be shown by Exception.getCause()? If so, what are the > possible Throwables that getCause will return for > XMultiComponentFactory.createInstanceWithContext? > > Or, am I limited to Exception.getMessage for reporting to the user? If there is a message that would be better than nothing. :-) As I wrote, I don't know which particular exception you get here, I would expect to get a css.lang.ServiceNotRegisteredException. Maybe it's described in the Developers Guide? Best regards, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
