A community based topic aggregation platform built on atproto
1package comments
2
3import "errors"
4
5var (
6 // ErrCommentNotFound indicates the requested comment doesn't exist
7 ErrCommentNotFound = errors.New("comment not found")
8
9 // ErrInvalidReply indicates the reply reference is malformed or invalid
10 ErrInvalidReply = errors.New("invalid reply reference")
11
12 // ErrParentNotFound indicates the parent post/comment doesn't exist
13 ErrParentNotFound = errors.New("parent post or comment not found")
14
15 // ErrRootNotFound indicates the root post doesn't exist
16 ErrRootNotFound = errors.New("root post not found")
17
18 // ErrContentTooLong indicates comment content exceeds 3000 graphemes
19 ErrContentTooLong = errors.New("comment content exceeds 3000 graphemes")
20
21 // ErrContentEmpty indicates comment content is empty
22 ErrContentEmpty = errors.New("comment content is required")
23
24 // ErrNotAuthorized indicates the user is not authorized to perform this action
25 ErrNotAuthorized = errors.New("not authorized")
26
27 // ErrBanned indicates the user is banned from the community
28 ErrBanned = errors.New("user is banned from this community")
29
30 // ErrCommentAlreadyExists indicates a comment with this URI already exists
31 ErrCommentAlreadyExists = errors.New("comment already exists")
32)
33
34// IsNotFound checks if an error is a "not found" error
35func IsNotFound(err error) bool {
36 return errors.Is(err, ErrCommentNotFound) ||
37 errors.Is(err, ErrParentNotFound) ||
38 errors.Is(err, ErrRootNotFound)
39}
40
41// IsConflict checks if an error is a conflict/already exists error
42func IsConflict(err error) bool {
43 return errors.Is(err, ErrCommentAlreadyExists)
44}
45
46// IsValidationError checks if an error is a validation error
47func IsValidationError(err error) bool {
48 return errors.Is(err, ErrInvalidReply) ||
49 errors.Is(err, ErrContentTooLong) ||
50 errors.Is(err, ErrContentEmpty)
51}