aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwagner riffel <w@104d.net>2021-04-09 16:26:09 -0300
committerReto Brunner <reto@labrat.space>2021-04-12 18:21:03 +0200
commita555343893601077ace03a2d44abfccc6f92db09 (patch)
treede75a3a67c225fd892bc044b133f9ea8338815c8
parent548facab929fa9ff70e804b990a89731cb8f82c0 (diff)
downloadaerc-a555343893601077ace03a2d44abfccc6f92db09.tar.gz
config: proper error handle [filters] config
Instead of panic when compiling a regular expression, return it up Signed-off-by: wagner riffel <w@104d.net>
-rw-r--r--config/config.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/config/config.go b/config/config.go
index 8b409fe7..80322018 100644
--- a/config/config.go
+++ b/config/config.go
@@ -304,7 +304,7 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
filter.Header = strings.ToLower(header)
filter.Regex, err = regexp.Compile(regex)
if err != nil {
- panic(err)
+ return err
}
} else if strings.ContainsRune(match, ',') {
filter.FilterType = FILTER_HEADER
@@ -312,6 +312,9 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
value := filter.Filter[strings.Index(filter.Filter, ",")+1:]
filter.Header = strings.ToLower(header)
filter.Regex, err = regexp.Compile(regexp.QuoteMeta(value))
+ if err != nil {
+ return err
+ }
} else {
filter.FilterType = FILTER_MIMETYPE
}