Skip to content

ToolHandle: throw exception if retrieval fails

If a ToolHandle is retrieved with the wrong interface, an StatusCode::FAILURE is returned, but no error message is displayed. This is especially bad when ToolHandles are automatically retrieved by their parent at the end of initialize - initialization will fail with no obvious cause.

This MR addresses this by having ToolHandle::retrieve throw an exception if either the retrieval from the ToolSvc fails, or if the dcast to the required iface fails.

I'm a bit torn about this however. We've gone from returning a StatusCode::FAILURE, which can easily be dealt with at runtime, to throwing an exception, which requires significantly different behaviour from the client. I don't know if there is a real use case for continuing execution if the retrieval fails. I think the best solution would have been to print an error message, and return a FAILURE as before, but there's no easy way to get hold of the MessageSvc from within the ToolHandle.

Merge request reports