refac: article title rules are the same in the API request and the domain; an invalid title returns 400 instead of 500

This commit is contained in:
fsylvain committed 2026-09-23 20:04:09 +02:00
1 parent ff8cd5f0ec
commit 4278d96882
9 files changed
+456 -7

No files matched your search

+12
View File
@@ -6,15 +6,27 @@ var errRepositoryFailure = errors.New("repository failure")
type failSwitch struct {
method string
err error
}
func (f *failSwitch) failNext(method string) {
f.method = method
f.err = nil
}
func (f *failSwitch) failNextWith(method string, err error) {
f.method = method
f.err = err
}
func (f *failSwitch) trigger(method string) error {
if f.method == method {
f.method = ""
if f.err != nil {
err := f.err
f.err = nil
return err
}
return errRepositoryFailure
}
return nil