able to list products

This commit is contained in:
Gitea
2023-11-23 19:13:54 +03:00
parent f382d9e73b
commit 0553ea71c3
11 changed files with 774 additions and 116 deletions

View File

@ -1,7 +1,12 @@
package domain
import (
"fmt"
)
const (
UnexpectedStatusError SimpleError = "unexpected status"
ErrNotImplemented SimpleError = "not implemented"
ErrUnexpectedStatus SimpleError = "unexpected status"
)
type SimpleError string
@ -9,3 +14,23 @@ type SimpleError string
func (err SimpleError) Error() string {
return string(err)
}
type ValidationError struct {
Field string
Reason string
}
func (err *ValidationError) Error() string {
return fmt.Sprintf("field %s is not valid for reason %s", err.Field, err.Reason)
}
func NewValidationError(field, reason string) *ValidationError {
if field == "" {
panic("field not provided")
}
return &ValidationError{
Field: field,
Reason: reason,
}
}