diff --git a/pkg/capabilities/errors/error.go b/pkg/capabilities/errors/error.go index 86f4d00b4..ed92a1196 100644 --- a/pkg/capabilities/errors/error.go +++ b/pkg/capabilities/errors/error.go @@ -1,6 +1,8 @@ package errors -import "fmt" +import ( + "fmt" +) type Origin int @@ -110,6 +112,12 @@ func NewPublicUserError(err error, errorCode ErrorCode) Error { return NewError(err, VisibilityPublic, OriginUser, errorCode) } +// NewLimitBreachedError creates a public user error that embeds the provided limit error, indicating that a CRE limit +// breach has occurred. The error message will include the provided errorMsg as a prefix for additional context. +func NewLimitBreachedError(errorMsg string, err error) Error { + return NewPublicUserError(fmt.Errorf("%s: %w", errorMsg, err), LimitExceeded) +} + // NewPrivateSystemError indicates that the wrapped error is due to a system-level issue and may contain // sensitive information that should only be visible to the node on which it occurred. The error code will still be // visible to other nodes in the network.