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.
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?
That XMultiComponentFactory.createInstanceWithContext is specified to throw Exception means just that and not more: It may throw Exception and any of the exceptions derived from it. And whether getCause is set to something useful is a QOI issue. This interface really only gives you a binary answer: If createInstanceWithContext returns a non-null XInterface, you know that your request succeeded; if it returns null or throws any exception, you know that your request did not succeed, but you have no robust way to know why it did not succeed. (Which might or might not be considered a design bug of createInstanceWithContext.)
-Stephan
thanks, mike
--- Mathias Bauer <[EMAIL PROTECTED]> wrote:
Mike Traum wrote:
My understanding is that when using the Bootstrap, you cannot
detect
what version of OOo you're connected to.
So, what is the best practice when you're using services that
have
been newly (or even not so newly) added to the api?
For example, I'm using the 'com.sun.star.gallery.GalleryThemeProvider' service, which is new
to
1.9.xx. Is the best practice to create instances of all of your services on startup, and then catch the Exception, which will
tell
you that it's unsupported?
Of course not all services on startup. You should try to create your services *when you need them* and if you fail to create them you must deal with the error. There are other reasons than the wrong version that let the creation of services fail, so you need the error handling anyway. What could a version information add to this?
It is an essential element of the OOo API that functionality is queried dynamically at runtime.
Being that the general 'Exception' is thrown on XMultiComponentFactory.createInstanceWithContext, is this the
only
case where the Exception will be thrown so that I do have a
reliable
way of detecting this specific error?
Sorry, I don't understand this. What general Exception are you talking about?
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]
