Use errors.Is to check for a specific error
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
This commit is contained in:
parent
06fa41c401
commit
92c0f9c962
|
@ -1,6 +1,7 @@
|
||||||
package genericresource
|
package genericresource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
@ -158,7 +159,7 @@ func expandIfFilePattern(pattern string) ([]string, error) {
|
||||||
if err == nil && len(matches) == 0 {
|
if err == nil && len(matches) == 0 {
|
||||||
return nil, fmt.Errorf("the path %q does not exist", pattern)
|
return nil, fmt.Errorf("the path %q does not exist", pattern)
|
||||||
}
|
}
|
||||||
if err == filepath.ErrBadPattern {
|
if errors.Is(err, filepath.ErrBadPattern) {
|
||||||
return nil, fmt.Errorf("pattern %q is not valid: %v", pattern, err)
|
return nil, fmt.Errorf("pattern %q is not valid: %v", pattern, err)
|
||||||
}
|
}
|
||||||
return matches, err
|
return matches, err
|
||||||
|
|
Loading…
Reference in New Issue