Difference between revisions of "Documentation/DevGuide/ProUNO/Exceptions"

From Apache OpenOffice Wiki
Jump to: navigation, search
(4 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/ProUNO/Singletons
 
|NextPage=Documentation/DevGuide/ProUNO/Singletons
 
}}
 
}}
 +
{{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/{{SUBPAGENAME}}}}
 
{{DISPLAYTITLE:Exceptions}}
 
{{DISPLAYTITLE:Exceptions}}
 
An <code>exception</code> type indicates an error to the caller of a function. The type of an exception gives a basic description of the kind of error that occurred. In addition, the UNO IDL <code>exception</code> types contain elements which allow for an exact specification and a detailed description of the error. The <code>exception</code> 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.
 
An <code>exception</code> type indicates an error to the caller of a function. The type of an exception gives a basic description of the kind of error that occurred. In addition, the UNO IDL <code>exception</code> types contain elements which allow for an exact specification and a detailed description of the error. The <code>exception</code> 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.
Line 28: Line 29:
 
Exceptions may only be thrown by operations which were specified to do so. In contrast, <idl>com.sun.star.uno.RuntimeException</idl>s can always occur.
 
Exceptions may only be thrown by operations which were specified to do so. In contrast, <idl>com.sun.star.uno.RuntimeException</idl>s can always occur.
  
{{Documentation/Caution|The methods <tt>acquire()</tt> and release of the UNO base interface <idl>com.sun.star.uno.XInterface</idl> 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.}}
+
{{Warn|The methods <tt>acquire()</tt> and release of the UNO base interface <idl>com.sun.star.uno.XInterface</idl> 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.}}
  
 
{{PDL1}}
 
{{PDL1}}
[[Category: Professional UNO]]
+
 
 +
[[Category:Documentation/Developer's Guide/Professional UNO]]

Revision as of 07:38, 12 July 2018



An exception type indicates an error to the caller of a function. The type of an 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