Skip to content

Conversation

@kurotych
Copy link
Member

@kurotych kurotych commented Mar 27, 2025

Return error in average_distance and multiplier functions instead of panic

@kurotych kurotych requested a review from Copilot March 27, 2025 15:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the error handling in two functions to return errors instead of panicking when encountering empty input arrays. The changes ensure that both average_distance and multiplier functions propagate errors, while the calling code in mobile_verifier and in other modules is updated to handle these errors.

  • Refactored average_distance and multiplier functions to return Result types.
  • Updated error propagation in lib.rs and logging in mobile_verifier.
  • Added tests to confirm that empty inputs return errors.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
mobile_verifier/src/reward_shares.rs Updated multiplier usage to handle the Result variant.
coverage_point_calculator/src/location.rs Changed average_distance and multiplier to return Results.
coverage_point_calculator/src/lib.rs Propagated errors using '?' and updated SPBoostedHexStatus.

@kurotych kurotych changed the title Reproduce panic tests Return error in average_distance and multiplier functions instead of panic Mar 27, 2025
@kurotych kurotych marked this pull request as ready for review March 27, 2025 15:47
@kurotych kurotych merged commit 2924ac6 into main Apr 2, 2025
27 checks passed
@kurotych kurotych deleted the fix-panic-coverage_point_calculator branch April 2, 2025 19:06
macpie pushed a commit that referenced this pull request Apr 14, 2025
macpie pushed a commit that referenced this pull request Apr 14, 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.

4 participants