Adding new errors and centralising handling

This commit is contained in:
2026-03-18 22:41:22 +00:00
parent 8749ff3c03
commit a33cedf09e
3 changed files with 77 additions and 10 deletions

View File

@@ -0,0 +1,35 @@
package repository
import (
"fmt"
"git.hrafn.xyz/aether/notes/internal/models"
)
type EmptyContent struct {}
type EmptyTitle struct {}
type NoOP struct {}
type EmptyUpdate struct{}
type TitleOverflow struct {
length int
}
func (e *EmptyContent) Error() string {
return "content cannot be empty"
}
func (e *EmptyTitle) Error() string {
return "title cannot be empty"
}
func (e *NoOP) Error() string {
return "no operation required"
}
func (e *EmptyUpdate) Error() string {
return "update cannot be empty"
}
func (e *TitleOverflow) Error() string {
return fmt.Sprintf("title max length %d, %d provided", models.NoteTitleMaxLength, e.length)
}