Adding new errors and centralising handling
This commit is contained in:
35
internal/repository/errors.go
Normal file
35
internal/repository/errors.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user