More graceful handling of bad match functions
This commit is contained in:
parent
2123308227
commit
2dad184dcf
12
config.go
12
config.go
@ -51,12 +51,18 @@ func MakeMatchFunc(rule string) MatchFunc {
|
||||
"hostname": dest.Hostname(),
|
||||
"url": dest,
|
||||
}
|
||||
matchFunc, err := expr.Eval(rule, env)
|
||||
matchFuncExpr, err := expr.Eval(rule, env)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
fmt.Printf("Error evaluating rule %s: %v", rule, err)
|
||||
return false
|
||||
}
|
||||
|
||||
return matchFunc.(MatchFunc)(dest)
|
||||
matchFunc, ok := matchFuncExpr.(MatchFunc)
|
||||
if !ok {
|
||||
fmt.Printf("Error evaluating rule %s. Did not evaluate to a MatchFunc.", rule)
|
||||
return false
|
||||
}
|
||||
return matchFunc(dest)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user