package domain type ErrorType uint8 const ( ErrorTypeUnknown ErrorType = iota ErrorTypeNotFound ErrorTypeIncorrectInput ) func (e ErrorType) String() string { switch e { case ErrorTypeNotFound: return "not found" case ErrorTypeIncorrectInput: return "incorrect input" case ErrorTypeUnknown: fallthrough default: return "unknown error" } } type Error interface { error Type() ErrorType Code() string } type ErrorWithParams interface { Error Params() map[string]any } type simpleError struct { msg string typ ErrorType code string } var _ Error = simpleError{} func (e simpleError) Error() string { return e.msg } func (e simpleError) Type() ErrorType { return e.typ } func (e simpleError) Code() string { return e.code }