-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.exceptions.ts
More file actions
67 lines (57 loc) · 1.62 KB
/
Copy pathtask.exceptions.ts
File metadata and controls
67 lines (57 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {
BadRequestException,
ConflictException,
NotFoundException,
} from '@nestjs/common';
import { ErrorCode, HasErrorCode } from '../../common/exceptions/error-codes';
import { TaskStatus } from '../entities/task-status.enum';
/** Task id did not resolve to a stored task. */
export class TaskNotFoundException
extends NotFoundException
implements HasErrorCode
{
readonly code = ErrorCode.TaskNotFound;
constructor(id: string) {
super(`Task ${id} not found`);
}
}
/** A status change that the transition state machine forbids. */
export class IllegalStatusTransitionException
extends ConflictException
implements HasErrorCode
{
readonly code = ErrorCode.IllegalStatusTransition;
constructor(from: TaskStatus, to: TaskStatus) {
super(`Illegal status transition: ${from} → ${to}`);
}
}
/** A partial update that carried no updatable fields. */
export class EmptyUpdateException
extends BadRequestException
implements HasErrorCode
{
readonly code = ErrorCode.EmptyUpdate;
constructor() {
super('Update payload must contain at least one field');
}
}
/** Attempt to mutate a task that has been archived (read-only). */
export class TaskArchivedException
extends ConflictException
implements HasErrorCode
{
readonly code = ErrorCode.TaskArchivedReadonly;
constructor() {
super('Archived tasks are read-only');
}
}
/** Pagination cursor that does not match any task in the result set. */
export class InvalidCursorException
extends BadRequestException
implements HasErrorCode
{
readonly code = ErrorCode.InvalidCursor;
constructor() {
super('Invalid pagination cursor');
}
}