github.com/TeaOSLab/EdgeNode@v1.3.8/internal/firewalls/nftables/errors.go (about)

     1  // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
     2  //go:build linux
     3  // +build linux
     4  
     5  package nftables
     6  
     7  import (
     8  	"errors"
     9  	"strings"
    10  )
    11  
    12  var ErrTableNotFound = errors.New("table not found")
    13  var ErrChainNotFound = errors.New("chain not found")
    14  var ErrSetNotFound = errors.New("set not found")
    15  var ErrRuleNotFound = errors.New("rule not found")
    16  
    17  func IsNotFound(err error) bool {
    18  	if err == nil {
    19  		return false
    20  	}
    21  	return err == ErrTableNotFound || err == ErrChainNotFound || err == ErrSetNotFound || err == ErrRuleNotFound || strings.Contains(err.Error(), "no such file or directory")
    22  }