1
1
package credentials
2
2
3
+ import "errors"
4
+
3
5
const (
4
6
// ErrCredentialsNotFound standardizes the not found error, so every helper returns
5
7
// the same message and docker can handle it properly.
@@ -30,8 +32,8 @@ func NewErrCredentialsNotFound() error {
30
32
// IsErrCredentialsNotFound returns true if the error
31
33
// was caused by not having a set of credentials in a store.
32
34
func IsErrCredentialsNotFound (err error ) bool {
33
- _ , ok := err .( errCredentialsNotFound )
34
- return ok
35
+ var target errCredentialsNotFound
36
+ return errors . As ( err , & target )
35
37
}
36
38
37
39
// IsErrCredentialsNotFoundMessage returns true if the error
@@ -78,8 +80,8 @@ func NewErrCredentialsMissingUsername() error {
78
80
// IsCredentialsMissingServerURL returns true if the error
79
81
// was an errCredentialsMissingServerURL.
80
82
func IsCredentialsMissingServerURL (err error ) bool {
81
- _ , ok := err .( errCredentialsMissingServerURL )
82
- return ok
83
+ var target errCredentialsMissingServerURL
84
+ return errors . As ( err , & target )
83
85
}
84
86
85
87
// IsCredentialsMissingServerURLMessage checks for an
@@ -91,8 +93,8 @@ func IsCredentialsMissingServerURLMessage(err string) bool {
91
93
// IsCredentialsMissingUsername returns true if the error
92
94
// was an errCredentialsMissingUsername.
93
95
func IsCredentialsMissingUsername (err error ) bool {
94
- _ , ok := err .( errCredentialsMissingUsername )
95
- return ok
96
+ var target errCredentialsMissingUsername
97
+ return errors . As ( err , & target )
96
98
}
97
99
98
100
// IsCredentialsMissingUsernameMessage checks for an
0 commit comments