Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return error if branch not found in child order #364

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

crodriguezvega
Copy link
Contributor

No description provided.

go/proof.go Outdated
}
}
panic(fmt.Errorf("branch %d not found in order %v", branch, order))

return 0, fmt.Errorf("branch %d not found in order %v", branch, order)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is basically the change needed. The rest of changes are for bubbling the error up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively I could have just swallowed the error in the call sites of getPosition and return in those places the default value (false, and 0s). I thought of bubbling the error up in case we ever do #29.

go/proof.go Outdated
if branch < 0 || int(branch) >= len(order) {
panic(fmt.Errorf("invalid branch: %d", branch))
return 0, fmt.Errorf("invalid branch: %d", branch)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also converted this one into a regular error instead of panicking.

idx, err := orderFromPadding(spec, op)
if err != nil {
return false
return false, err
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here an error that previously was swallowed can now be returned.

go/proof.go Outdated
idx, err := orderFromPadding(spec, op)
if err != nil {
return false
return false, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another one that previously was swallowed.

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.

1 participant