errors.ts raw
1 /**
2 * Domain errors for Content bounded context
3 */
4
5 import { DomainError } from '../shared'
6
7 /**
8 * Thrown when content validation fails
9 */
10 export class InvalidContentError extends DomainError {
11 constructor(reason: string) {
12 super(`Invalid content: ${reason}`)
13 }
14 }
15
16 /**
17 * Thrown when a note operation fails
18 */
19 export class NoteOperationError extends DomainError {
20 constructor(operation: string, reason?: string) {
21 super(`Note operation failed: ${operation}${reason ? ` - ${reason}` : ''}`)
22 }
23 }
24
25 /**
26 * Thrown when attempting to react to own content
27 */
28 export class CannotReactToOwnContentError extends DomainError {
29 constructor() {
30 super('Cannot react to your own content')
31 }
32 }
33
34 /**
35 * Thrown when a note is not found
36 */
37 export class NoteNotFoundError extends DomainError {
38 constructor(id: string) {
39 super(`Note not found: ${id}`)
40 }
41 }
42
43 /**
44 * Thrown when content exceeds size limits
45 */
46 export class ContentTooLargeError extends DomainError {
47 constructor(maxSize: number) {
48 super(`Content exceeds maximum size of ${maxSize} characters`)
49 }
50 }
51