Skip to content

Commit a228f55

Browse files
committed
credentials: implement errdefs types for typed errors
This allows for checking the error-type returned to be matched with the errdefs utilities. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent dbfb389 commit a228f55

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

credentials/error.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ func (errCredentialsNotFound) Error() string {
2323
return errCredentialsNotFoundMessage
2424
}
2525

26+
// NotFound implements the [ErrNotFound][errdefs.ErrNotFound] interface.
27+
//
28+
// [errdefs.ErrNotFound]: https://pkg.go.dev/github.com/docker/[email protected]+incompatible/errdefs#ErrNotFound
29+
func (errCredentialsNotFound) NotFound() {}
30+
2631
// NewErrCredentialsNotFound creates a new error
2732
// for when the credentials are not in the store.
2833
func NewErrCredentialsNotFound() error {
@@ -55,6 +60,12 @@ func (errCredentialsMissingServerURL) Error() string {
5560
return errCredentialsMissingServerURLMessage
5661
}
5762

63+
// InvalidParameter implements the [ErrInvalidParameter][errdefs.ErrInvalidParameter]
64+
// interface.
65+
//
66+
// [errdefs.ErrInvalidParameter]: https://pkg.go.dev/github.com/docker/[email protected]+incompatible/errdefs#ErrInvalidParameter
67+
func (errCredentialsMissingServerURL) InvalidParameter() {}
68+
5869
// errCredentialsMissingUsername represents an error raised
5970
// when the credentials object has no username or when no
6071
// username is provided to a credentials operation requiring
@@ -65,6 +76,12 @@ func (errCredentialsMissingUsername) Error() string {
6576
return errCredentialsMissingUsernameMessage
6677
}
6778

79+
// InvalidParameter implements the [ErrInvalidParameter][errdefs.ErrInvalidParameter]
80+
// interface.
81+
//
82+
// [errdefs.ErrInvalidParameter]: https://pkg.go.dev/github.com/docker/[email protected]+incompatible/errdefs#ErrInvalidParameter
83+
func (errCredentialsMissingUsername) InvalidParameter() {}
84+
6885
// NewErrCredentialsMissingServerURL creates a new error for
6986
// errCredentialsMissingServerURL.
7087
func NewErrCredentialsMissingServerURL() error {

0 commit comments

Comments
 (0)