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

Inconsistent Error Handling in nat Package #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ashwek
Copy link

@ashwek ashwek commented Jan 16, 2024

Fixes #112

Comment on lines +91 to +94
// We don't need to check for an error because we're going to
// assume that any error would have been found, and reported, in NewPort()
start, end, _ := ParsePortRangeToInt(p.Port())
return start, end, nil
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit on the fence here; the Int() function does not have an error-return in its signature, so even if the error would not be ignored, there's nowhere to send it to (other than logging or a panic);

// Int returns the port number of a Port as an int
func (p Port) Int() int {
portStr := p.Port()
// We don't need to check for an error because we're going to
// assume that any error would have been found, and reported, in NewPort()
port, _ := ParsePort(portStr)
return port
}

The Range() function does have an error return, so the error can be handled (or ignored) by consumers.

Was there an issue you ran into, other than error-handling being inconsistent?

(for transparency; the code in this repository is quite old, and not all parts are very well designed; we're still evaluating the future of this repository, and possibly breaking it up / moving code elsewhere)

Copy link
Author

Choose a reason for hiding this comment

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

No, inconsistent error handling was the only issue.

Okay, if there is a possibility that the code is being moved or broken up, this PR won't contribute much. I guess we can just close it.

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.

Inconsistent Error Handling in nat Package
2 participants