Skip to content

Commit

Permalink
feat: k8s wrapped errors
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie committed Feb 12, 2025
1 parent e66396a commit 90e5418
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions k8s/errorx/errorx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package errorx

import "k8s.io/apimachinery/pkg/api/errors"

// IsNotFound checks if an error is a not found error.
func IsNotFound(err error) bool {
return err != nil && errors.IsNotFound(err)
}

// IsAlreadyExists checks if an error is an already exists error.
func IsAlreadyExists(err error) bool {
return err != nil && errors.IsAlreadyExists(err)
}

// IsConflict checks if an error is a conflict error.
func IsConflict(err error) bool {
return err != nil && errors.IsConflict(err)
}

// IsInvalid checks if an error is an invalid error.
func IsInvalid(err error) bool {
return err != nil && errors.IsInvalid(err)
}

// IsUnauthorized checks if an error is an unauthorized error.
func IsUnauthorized(err error) bool {
return err != nil && errors.IsUnauthorized(err)
}

// IsForbidden checks if an error is a forbidden error.
func IsForbidden(err error) bool {
return err != nil && errors.IsForbidden(err)
}

// IsServiceUnavailable checks if an error is a service unavailable error.
func IsServiceUnavailable(err error) bool {
return err != nil && errors.IsServiceUnavailable(err)
}

// IsTimeout checks if an error is a timeout error.
func IsTimeout(err error) bool {
return err != nil && errors.IsTimeout(err)
}

// IsServerTimeout checks if an error is a server timeout error.
func IsServerTimeout(err error) bool {
return err != nil && errors.IsServerTimeout(err)
}

// IsGone checks if an error is a gone error.
func IsGone(err error) bool {
return err != nil && errors.IsGone(err)
}

// IsBadRequest checks if an error is a bad request error.
func IsBadRequest(err error) bool {
return err != nil && errors.IsBadRequest(err)
}

0 comments on commit 90e5418

Please sign in to comment.