mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-07 08:26:53 +00:00
36 lines
837 B
Go
36 lines
837 B
Go
|
package engine
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
type codeKey int
|
||
|
|
||
|
const (
|
||
|
conditionFailure codeKey = iota
|
||
|
overlayFailure
|
||
|
)
|
||
|
|
||
|
type overlayError struct {
|
||
|
statusCode codeKey
|
||
|
errorMsg string
|
||
|
}
|
||
|
|
||
|
// newOverlayError returns an overlay error using the statusCode and errorMsg
|
||
|
func newOverlayError(code codeKey, msg string) overlayError {
|
||
|
return overlayError{statusCode: code, errorMsg: msg}
|
||
|
}
|
||
|
|
||
|
// StatusCode returns the codeKey wrapped with status code of the overlay error
|
||
|
func (e overlayError) StatusCode() codeKey {
|
||
|
return e.statusCode
|
||
|
}
|
||
|
|
||
|
// ErrorMsg returns the string representation of the overlay error message
|
||
|
func (e overlayError) ErrorMsg() string {
|
||
|
return e.errorMsg
|
||
|
}
|
||
|
|
||
|
// Error returns the string representation of the overlay error
|
||
|
func (e overlayError) Error() string {
|
||
|
return fmt.Sprintf("[overlayError:%v] %v", e.statusCode, e.errorMsg)
|
||
|
}
|