Throw error instead of panicking
This commit is contained in:
@@ -99,17 +99,17 @@ func range2regex(start int, end int) (string, error) {
|
||||
// Last range - tmp to rangeEnd
|
||||
ranges = append(ranges, numRange{tmp, rangeEnd})
|
||||
|
||||
regex := "("
|
||||
regex := string(NONCAPLPAREN_CHAR)
|
||||
// Generate the regex
|
||||
for i, rg := range ranges {
|
||||
if i > 0 {
|
||||
regex += "|"
|
||||
}
|
||||
regex += "("
|
||||
regex += string(NONCAPLPAREN_CHAR)
|
||||
startSlc := intToSlc(rg.start)
|
||||
endSlc := intToSlc(rg.end)
|
||||
if len(startSlc) != len(endSlc) {
|
||||
panic("Ranges have unequal lengths.")
|
||||
return "", fmt.Errorf("Error parsing numeric range")
|
||||
}
|
||||
for i := range startSlc {
|
||||
if startSlc[i] == endSlc[i] {
|
||||
|
Reference in New Issue
Block a user