-
Notifications
You must be signed in to change notification settings - Fork 68
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
base: master
Are you sure you want to change the base?
Conversation
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
No description provided.