Difference between revisions of "Documentation/DevGuide/ProUNO/Exceptions"
From Apache OpenOffice Wiki
< Documentation | DevGuide
Line 8: | Line 8: | ||
{{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/{{SUBPAGENAME}}}} | {{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 26: | 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. | ||
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). |