~sircmpwn/aerc

a555343893601077ace03a2d44abfccc6f92db09 — wagner riffel 5 months ago 548faca
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>
1 files changed, 4 insertions(+), 1 deletions(-)

M config/config.go
M config/config.go => config/config.go +4 -1
@@ 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
			}