Difference between revisions of "Documentation/DevGuide/ProUNO/Exceptions"
From Apache OpenOffice Wiki
< Documentation | DevGuide
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Professional UNO) |
|||
(3 intermediate revisions by 3 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 <code>exception</code> 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 <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. |
UNO IDL requires that all exceptions must inherit from <idl>com.sun.star.uno.Exception</idl>. This is a precondition for the UNO runtime. | UNO IDL requires that all exceptions must inherit from <idl>com.sun.star.uno.Exception</idl>. This is a precondition for the UNO runtime. | ||
− | + | <syntaxhighlight lang="idl"> | |
// com.sun.star.uno.Exception is the base exception for all exceptions | // com.sun.star.uno.Exception is the base exception for all exceptions | ||
exception Exception { | exception Exception { | ||
Line 25: | Line 26: | ||
exception SecurityException : com::sun::star::uno::RuntimeException { | exception SecurityException : com::sun::star::uno::RuntimeException { | ||
}; | }; | ||
− | + | </syntaxhighlight> | |
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. | ||
− | {{ | + | {{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:Documentation/Developer's Guide/Professional UNO]] | [[Category:Documentation/Developer's Guide/Professional UNO]] |
Latest revision as of 10:44, 23 December 2020
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.
![]() |
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). |