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

GetInt should return default val instead of panic #75

Open
FarmerChillax opened this issue Apr 30, 2024 · 0 comments
Open

GetInt should return default val instead of panic #75

FarmerChillax opened this issue Apr 30, 2024 · 0 comments

Comments

@FarmerChillax
Copy link

In GetInt function should return default value instead of panic

// GetInt parses the expanded value as an int if the key exists.
// If key does not exist or the value cannot be parsed the default
// value is returned. If the value does not fit into an int the
// function panics with an out of range error.
func (p *Properties) GetInt(key string, def int) int {
	v, err := p.getInt64(key)
	if err != nil {
		return def
	}
	return intRangeCheck(key, v)
}

more:

panic(fmt.Sprintf("Value %d for key %s out of range", v, key))

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

No branches or pull requests

1 participant