Exceptions

From Apache OpenOffice Wiki
Jump to: navigation, search



An exception type indicates an error to the caller of a function. The type of exception gives a basic description of the kind of error that occurred. In addition, the UNO IDL exception types contain elements which allow for an exact specification and a detailed description of the error. The exception type supports inheritance, this is frequently used to define a hierarchy of errors. Exceptions are only used to raise errors, not as method parameters or return types.

UNO IDL requires that all exceptions must inherit from com.sun.star.uno.Exception. This is a precondition for the UNO runtime.

  // com.sun.star.uno.Exception is the base exception for all exceptions
  exception Exception {
      string Message;  
      Xinterface Context;
  };
 
  // com.sun.star.uno.RuntimeException is the base exception for serious problems
  // occuring at runtime, usually programming errors or problems in the runtime environment
  exception RuntimeException : com::sun::star::uno::Exception {
  };
 
  // com.sun.star.uno.SecurityException is a more specific RuntimeException 
  exception SecurityException : com::sun::star::uno::RuntimeException {
  };

Exceptions may only be thrown by operations which were specified to do so. In contrast, com.sun.star.uno.RuntimeExceptions can always occur.

Documentation caution.png The methods acquire() and release of the UNO base interface com.sun.star.uno.XInterface are an exception to the above rule. They are the only operations that may not even throw runtime exceptions. But in Java and C++ programs, you do not use these methods directly, they are handled by the respective language binding.
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages