Skip to content

Never return nullptr silently#2969

Open
sjahr wants to merge 14 commits intomoveit:mainfrom
sjahr:pr-never-silently-return-nullptr
Open

Never return nullptr silently#2969
sjahr wants to merge 14 commits intomoveit:mainfrom
sjahr:pr-never-silently-return-nullptr

Conversation

@sjahr
Copy link
Contributor

@sjahr sjahr commented Aug 12, 2024

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 sjahr requested review from Abishalini and marioprats August 12, 2024 09:27
Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issueing an error message before returning a nullptr is not always desired: It might be perfectly possible that the caller correctly handles the nullptr result and issues an error itself or handles the error condition gracefully in some other fashion.
In that case, the error message would be spurious.
At most, you should issue a debug message.

@marioprats
Copy link
Contributor

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.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sjahr
Copy link
Contributor Author

sjahr commented Aug 26, 2024

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 sjahr requested a review from rhaschke August 26, 2024 09:01
Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments below.

Co-authored-by: Robert Haschke <rhaschke@users.noreply.github.com>
@rhaschke
Copy link
Contributor

Sorry, I missed some closing parentheses.

Copy link
Contributor

@rhaschke rhaschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix parentheses. Still unchecked. I just did that in the Web GUI.

sjahr and others added 4 commits August 26, 2024 15:46
Co-authored-by: Robert Haschke <rhaschke@users.noreply.github.com>
Co-authored-by: Robert Haschke <rhaschke@users.noreply.github.com>
@henningkayser
Copy link
Member

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

@github-actions
Copy link

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 github-actions bot added the stale label Oct 21, 2024
@mergify
Copy link

mergify bot commented Oct 21, 2024

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

@github-actions github-actions bot removed the stale label Oct 22, 2024
@github-actions
Copy link

github-actions bot commented Dec 9, 2024

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 github-actions bot added the stale label Dec 9, 2024
@marioprats marioprats removed their request for review January 23, 2025 08:38
@github-actions github-actions bot removed the stale label Jan 23, 2025
@github-actions
Copy link

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 github-actions bot added the stale label Mar 10, 2025
@EzraBrooks EzraBrooks removed the stale label Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants