Return error instead of panicking if the range cannot be processed
This commit is contained in:
@@ -44,11 +44,11 @@ func intToSlc(val int) []int {
|
||||
return toRet
|
||||
}
|
||||
|
||||
func range2regex(start int, end int) string {
|
||||
func range2regex(start int, end int) (string, error) {
|
||||
rangeStart := start
|
||||
rangeEnd := end
|
||||
if rangeStart > rangeEnd {
|
||||
panic("Range start greater than range end.")
|
||||
return "", fmt.Errorf("numeric range start greater than range end")
|
||||
}
|
||||
|
||||
ranges := make([]numRange, 0)
|
||||
@@ -121,6 +121,6 @@ func range2regex(start int, end int) string {
|
||||
regex += ")"
|
||||
}
|
||||
regex += ")"
|
||||
return regex
|
||||
return regex, nil
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user