core/internal/domain/error.go

34 lines
512 B
Go

package domain
type ErrorCode uint8
const (
ErrorCodeUnknown ErrorCode = iota
ErrorCodeEntityNotFound
ErrorCodeIncorrectInput
)
func (e ErrorCode) String() string {
switch e {
case ErrorCodeEntityNotFound:
return "entity-not-found"
case ErrorCodeIncorrectInput:
return "incorrect-input"
case ErrorCodeUnknown:
fallthrough
default:
return "unknown-error"
}
}
type Error interface {
error
Code() ErrorCode
Slug() string
}
type ErrorWithParams interface {
Error
Params() map[string]any
}