Thanks to visit codestin.com
Credit goes to github.com

Skip to content

More informative exception if invalid access of image/camera/point3D#2825

Merged
ahojnnes merged 4 commits intomainfrom
sarlinpe/except-access
Oct 7, 2024
Merged

More informative exception if invalid access of image/camera/point3D#2825
ahojnnes merged 4 commits intomainfrom
sarlinpe/except-access

Conversation

@sarlinpe
Copy link
Member

@sarlinpe sarlinpe commented Oct 6, 2024

  • Calling reconstruction.Image(image_id) for a nonexistent image ID raises an exception with the uninformative message _Map_base::at. This is especially confusing for Python users. This PR makes the exception message more informative.
  • This PR also shares the implementations of the const and non-const getters, as suggested here: https://stackoverflow.com/a/856839 Does it still make sense to keep these implementations inlined?

@sarlinpe sarlinpe requested review from B1ueber2y and ahojnnes October 6, 2024 21:04
Copy link
Contributor

@ahojnnes ahojnnes left a comment

Choose a reason for hiding this comment

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

Thanks, lgtm.


struct Camera& Reconstruction::Camera(const camera_t camera_id) {
return cameras_.at(camera_id);
return const_cast<struct Camera&>(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest replicating the code here instead of the const cast. I am not sure if the compiler makes some optimizations with the const that then get violated by this const cast. Code replication is not all that bad and here the savings are also marginal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, done.

@sarlinpe sarlinpe requested a review from ahojnnes October 7, 2024 08:00
@ahojnnes ahojnnes enabled auto-merge (squash) October 7, 2024 08:05
@ahojnnes ahojnnes merged commit 8613afc into main Oct 7, 2024
@ahojnnes ahojnnes deleted the sarlinpe/except-access branch October 7, 2024 08:43
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.

3 participants