moveit2 icon indicating copy to clipboard operation
moveit2 copied to clipboard

Never return nullptr silently

Open sjahr opened this issue 1 year ago • 8 comments

Description

  • Create some warning/ error message before returning a nullptr for better debugability
  • Some minor documentation improvement

Checklist

  • [ ] Required by CI: Code is auto formatted using clang-format
  • [ ] Extend the tutorials / documentation reference
  • [ ] Document API changes relevant to the user in the MIGRATION.md notes
  • [ ] Create tests, which fail without this PR reference
  • [ ] Include a screenshot if changing a GUI
  • [ ] While waiting for someone to review your request, please help review another open pull request to support the maintainers

sjahr avatar Aug 12 '24 09:08 sjahr

I agree with Robert. The functions returning nullptr are indicative of an error, which the caller should handle. A better solution would be to introduce a good error propagation mechanism, like tl::expected or absl::Status. Then we could return an error with a string, and let the caller decide what to do. In the meanwhile I think a log message makes sense, but I would make it a debug message.

marioprats avatar Aug 14 '24 10:08 marioprats

The last commit (57a85c8) should be handled in a separate PR. This is a fundamental change of the API and logic, which should be well motivated. I don't yet see the "ugliness" of the current API. You should better address the reviews and change error messages to debug messages.

You're right, that derailed to initial intention of the PR too much, sorry. I reverted it and updated the log level to debug in most cases. Let me know what you think.

I don't yet see the "ugliness" of the current API.

Maybe isn't the right term but rather outdated. I think we shouldn't pass raw boolean pointers anywhere in modern C++ but as you pointed out correctly, this PR is not the place to try changing that.

sjahr avatar Aug 26 '24 09:08 sjahr

Sorry, I missed some closing parentheses.

rhaschke avatar Aug 26 '24 12:08 rhaschke

@sjahr unfortunately this needs a new iteration because I merged #2985

henningkayser avatar Sep 04 '24 17:09 henningkayser

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

github-actions[bot] avatar Oct 21 '24 12:10 github-actions[bot]

This pull request is in conflict. Could you fix it @sjahr?

mergify[bot] avatar Oct 21 '24 12:10 mergify[bot]

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

github-actions[bot] avatar Dec 09 '24 12:12 github-actions[bot]

This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete.

github-actions[bot] avatar Mar 10 '25 12:03 github-actions[bot]