lib/storage: handle errors returned from TagFilters.Add when cloning TagFilters with negative filter

This commit is contained in:
Aliaksandr Valialkin 2020-03-31 16:18:02 +03:00
parent e71519b8b2
commit b699c46046

View File

@ -88,9 +88,13 @@ func (tfs *TagFilters) cloneWithNegativeFilter(tfNegative *tagFilter) *TagFilter
for i := range tfs.tfs { for i := range tfs.tfs {
tf := &tfs.tfs[i] tf := &tfs.tfs[i]
if tf == tfNegative { if tf == tfNegative {
tfsNew.Add(tf.key, []byte(".+"), true, true) if err := tfsNew.Add(tf.key, []byte(".+"), true, true); err != nil {
logger.Panicf("BUG: unexpected error when creating a tag filter key=~'.+': %s", err)
}
} else { } else {
tfsNew.Add(tf.key, tf.value, tf.isNegative, tf.isRegexp) if err := tfsNew.Add(tf.key, tf.value, tf.isNegative, tf.isRegexp); err != nil {
logger.Panicf("BUG: unexpected error when cloning a tag filter %s: %s", tf, err)
}
} }
} }
return tfsNew return tfsNew