https://bugs.documentfoundation.org/show_bug.cgi?id=156776

--- Comment #28 from Lionel Elie Mamane <lio...@mamane.lu> ---
(In reply to Julien Nabet from comment #27)
> I don't want to click on Start Review because I think it'll remove WIP
> status.

Click there, then "Send as WiP" (not "Send and Start Review", that's what I
did).

> const Reference< XConnection2 > xCon2(_xConnection, UNO_QUERY);
> or
> const Reference< XConnection2 > xCon2(_xConnection, UNO_QUERY_THROW);

> now I'm not sure which one we should use and why.

That's important to understand.

UNO_QUERY (which I think/hope is the default and can just be omitted, but I'm a
bit rusty on details) means that if _xConnection does not implement the
XConnection2 interface, then xCon2 will be a NULL reference.

UNO_QUERY_THROW means that if _xConnection does not implement the XConnection2
interface, then a RuntimeException will be thrown; execution of the code block
is _stopped_, and everything goes up scope by scope until the exception is
caught.

Generally, UNO_QUERY is good when the situation (the requested interface is not
implemented) is handled locally, with an "if (xCon2.is())" as I suggested
should be done in this case.

Generally, UNO_QUERY_THROW is good when the code just cannot continue in this
situation, and the error must go up the stack until the error is handled.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to