Difference between revisions of "Documentation/DevGuide/ProUNO/Bridge/Exceptions and Errorcodes"
OOoWikiBot (Talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Professional UNO) |
OOoWikiBot (Talk | contribs) m (FINAL VERSION FOR L10N) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 7: | Line 7: | ||
|NextPage=Documentation/DevGuide/ProUNO/Bridge/Automation Objects with UNO Interfaces | |NextPage=Documentation/DevGuide/ProUNO/Bridge/Automation Objects with UNO Interfaces | ||
}} | }} | ||
+ | {{Documentation/DevGuideLanguages|Documentation/DevGuide/ProUNO/Bridge/{{SUBPAGENAME}}}} | ||
{{DISPLAYTITLE:Exceptions and Errorcodes}} | {{DISPLAYTITLE:Exceptions and Errorcodes}} | ||
<!--<idltopic>com.sun.star.uno.Exception;com.sun.star.uno.RuntimeException;com.sun.star.script.CannotConvertException;com.sun.star.reflection.InvocationTargetException</idltopic>--> | <!--<idltopic>com.sun.star.uno.Exception;com.sun.star.uno.RuntimeException;com.sun.star.script.CannotConvertException;com.sun.star.reflection.InvocationTargetException</idltopic>--> | ||
Line 27: | Line 28: | ||
|- | |- | ||
|<code>DISP_E_EXCEPTION</code> | |<code>DISP_E_EXCEPTION</code> | ||
− | |* UNO interface function or property access function threw an exception and the caller did not provide an <code>EXCEPINFO</code> argument. | + | | |
+ | * UNO interface function or property access function threw an exception and the caller did not provide an <code>EXCEPINFO</code> argument. | ||
* Bridge error. A <code>ValueObject</code> could not be created when the client called <code>Bridge_GetValueObject</code>. | * Bridge error. A <code>ValueObject</code> could not be created when the client called <code>Bridge_GetValueObject</code>. | ||
* Bridge error. A struct could not be created when the client called <code>Bridge_GetStruct</code>. | * Bridge error. A struct could not be created when the client called <code>Bridge_GetStruct</code>. | ||
Line 37: | Line 39: | ||
|- | |- | ||
|<code>DISP_E_NONAMEDARGS</code> | |<code>DISP_E_NONAMEDARGS</code> | ||
− | |* The caller provided "named arguments" for a call to a UNO function. | + | | |
+ | * The caller provided "named arguments" for a call to a UNO function. | ||
|- | |- | ||
|<code>DISP_E_BADVARTYPE</code> | |<code>DISP_E_BADVARTYPE</code> | ||
− | |* Conversion of <code>VARIANTARG</code>s failed. | + | | |
+ | * Conversion of <code>VARIANTARG</code>s failed. | ||
* Bridge error: Caller provided a <code>ValueObject</code> and the attempt to retrieve the value failed. This is possibly a bug. <code>DISP_E_EXCEPTION</code> should be returned. | * Bridge error: Caller provided a <code>ValueObject</code> and the attempt to retrieve the value failed. This is possibly a bug. <code>DISP_E_EXCEPTION</code> should be returned. | ||
* A member with the current name does not exist according to type information. This is a bug. <code>DISP_E_MEMBERNOTFOUND</code> should be returned. | * A member with the current name does not exist according to type information. This is a bug. <code>DISP_E_MEMBERNOTFOUND</code> should be returned. | ||
Line 46: | Line 50: | ||
|- | |- | ||
|<code>DISP_E_BADPARAMCOUNT</code> | |<code>DISP_E_BADPARAMCOUNT</code> | ||
− | |* A property was assigned a value and the caller provided null or more than one arguments. | + | | |
+ | * A property was assigned a value and the caller provided null or more than one arguments. | ||
* The caller did not provide the number of arguments as required by the UNO interface function. | * The caller did not provide the number of arguments as required by the UNO interface function. | ||
* <code>Bridge_CreateType</code> was called where the number of arguments was not one. | * <code>Bridge_CreateType</code> was called where the number of arguments was not one. | ||
|- | |- | ||
|<code>DISP_E_MEMBERNOTFOUND</code> | |<code>DISP_E_MEMBERNOTFOUND</code> | ||
− | |* Invoke was called with a <code>DISPID</code> that was not issued by <code>GetIDsOfName</code>. | + | | |
+ | * Invoke was called with a <code>DISPID</code> that was not issued by <code>GetIDsOfName</code>. | ||
* There is no interface function (also property access function) with the name for which Invoke is currently being called. | * There is no interface function (also property access function) with the name for which Invoke is currently being called. | ||
|- | |- |
Latest revision as of 08:21, 13 May 2009
UNO interface functions may throw exceptions to communicate an error. Automation objects provide a different error mechanism. First, the IDispatch
interface describes a number of error codes (HRESULT
s) that are returned under certain conditions. Second, the Invoke
function takes an argument that can be used by the object to provide descriptive error information. The argument is a structure of type EXCEPINFO
and is used by the bridge to convey exceptions being thrown by the called UNO interface function. In case the UNO method throws an exception the bridge fills EXCEPINFO
with these values:
EXCEPINFO::wCode = 1001 EXCEPINFO::bstrSource = "[automation bridge]" EXCEPINFO::bstrDescription = type name of the exceptions + the message of the exception (com::sun::star::uno::Exception::message )
Also the returned error code will be DISP_E_EXCEPTION
.
Since the automation bridge processes the Invoke call and calls the respective UNO method in the end, there can be other errors which are not caused by the UNO method itself. The following table shows what these errors are and how they are caused.
HRESULT | Reason |
---|---|
DISP_E_EXCEPTION
|
|
DISP_E_NONAMEDARGS
|
|
DISP_E_BADVARTYPE
|
|
DISP_E_BADPARAMCOUNT
|
|
DISP_E_MEMBERNOTFOUND
|
|
DISP_E_TYPEMISMATCH
|
The called provided an argument of a false type. |
DISP_E_OVERFLOW
|
An argument could not be coerced to the expected type. Internal call to XInvocation::invoke resulted in a CannotConvertException< code> being thrown. The field reason has the value OUT_OF_RANGE which means that a given value did not fit in the range of the destination type.
|
E_UNEXPECTED
|
[2]results from com.sun.star.script.CannotConvertException of XInvocation::invoke with FailReason::UNKNOWN . Internal call to XInvocation::invoke resulted in a com.sun.star.script.CannotConvertException being thrown. The field reason has the value UNKNOWN , which signifies some unknown error condition.
|
E_POINTER
|
Bridge_GetValueObject or Bridge_GetStruct called and no argument for return value provided.
|
S_OK
|
Ok. |
Return values of IDispatch::GetIDsOfNames:
HRESULT | Reason |
---|---|
E_POINTER
|
Caller provided no argument that receives the DISPID .
|
DISP_E_UNKNOWNNAME
|
There is no function or property with the given name. |
S_OK
|
Ok. |
The functions IDispatch::GetTypeInfo
and GetTypeInfoCount
return E_NOTIMPL
.
When a call from UNO to an Automation object is performed, then the following HRESULT
values are converted to exceptions. Keep in mind that it is determined what exceptions the functions of XInvocation
are allowed to throw.
Exceptions thrown by XInvocation::invoke()
and their HRESULT
counterparts:
HRESULT | Exception |
---|---|
DISP_E_BADPARAMCOUNT
|
com.sun.star.lang.IllegalArgumentException |
DISP_E_BADVARTYPE
|
com.sun.star.uno.RuntimeException |
DISP_E_EXCEPTION
|
com.sun.star.reflection.InvocationTargetException |
DISP_E_MEMBERNOTFOUND
|
com.sun.star.lang.IllegalArgumentException |
DISP_E_NONAMEDARGS
|
com.sun.star.lang.IllegalArgumentException |
DISP_E_OVERFLOW
|
com.sun.star.script.CannotConvertException, reason= FailReason::OUT_OF_RANGE
|
DISP_E_PARAMNOTFOUND
|
com.sun.star.lang.IllegalArgumentException |
DISP_E_TYPEMISMATCH
|
com.sun.star.script.CannotConvertException, reason= FailReason::UNKNOWN
|
DISP_E_UNKNOWNINTERFACE
|
com.sun.star.uno.RuntimeException |
DISP_E_UNKNOWNLCID
|
com.sun.star.uno.RuntimeException |
DISP_E_PARAMNOTOPTIONAL
|
com.sun.star.script.CannotConvertException, reason= FailReason::NO_DEFAULT_AVAILABLE
|
XInvocation::setValue()
throws the same as invoke()
except for:
HRESULT | Exception |
---|---|
DISP_E_BADPARAMCOUNT
|
com.sun.star.uno.RuntimeException |
DISP_E_MEMBERNOTFOUND
|
com.sun.star.beans.UnknownPropertyException |
DISP_E_NONAMEDARGS
|
com.sun.star.uno.RuntimeException |
XInvocation::getValue()
throws the same as invoke() except for:
HRESULT | Exception |
---|---|
DISP_E_BADPARAMCOUNT
|
com.sun.star.uno.RuntimeException |
DISP_E_EXCEPTION
|
com.sun.star.uno.RuntimeException |
DISP_E_MEMBERNOTFOUND
|
com.sun.star.beans.UnknownPropertyException |
DISP_E_NONAMEDARGS
|
com.sun.star.uno.RuntimeException |
DISP_E_OVERFLOW
|
com.sun.star.uno.RuntimeException |
DISP_E_PARAMNOTFOUND
|
com.sun.star.uno.RuntimeException |
DISP_E_TYPEMISMATCH
|
com.sun.star.uno.RuntimeException |
DISP_E_PARAMNOTOPTIONAL
|
com.sun.star.uno.RuntimeException |
Content on this page is licensed under the Public Documentation License (PDL). |